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
|
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
|
const mobile = parseInt( |
|
config.themes.default.theme.breakpoints.mobile.replace("px", "") |
|
); |
|
const tablet = parseInt( |
|
config.themes.default.theme.breakpoints.tablet.replace("px", "") |
|
); |
Feature Request
I wanted to use
useResponsivecomponent but I can see some problems with it:ui-kit/src/hooks/useResponsive.tsx
Lines 13 to 23 in e2c86ed
ui-kit/src/hooks/useResponsive.tsx
Lines 6 to 11 in e2c86ed