-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
Feature Request
I wanted to use useResponsive
component but I can see some problems with it:
- ⚡️ if you use let's say 10 times the hooks, you will have 10 times a listener on "resize", when just one should be enough for all the application
- ⚡️"resize" is triggered many times during a window resizing, good practice to add a debounce
ui-kit/src/hooks/useResponsive.tsx
Lines 13 to 23 in e2c86ed
const handleWindowSizeChange = () => { setWidth(window.innerWidth); }; useEffect(() => { window.addEventListener("resize", handleWindowSizeChange); return () => { window.removeEventListener("resize", handleWindowSizeChange); }; }, []); - 🐛it uses the default breakpoints, so we cannot leverage the Cunningham theming
ui-kit/src/hooks/useResponsive.tsx
Lines 6 to 11 in e2c86ed
const mobile = parseInt( config.themes.default.theme.breakpoints.mobile.replace("px", "") ); const tablet = parseInt( config.themes.default.theme.breakpoints.tablet.replace("px", "") );
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request