You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, we can do useBreakpoint('md lg'). Instead we should support useBreakpoint(['md', 'lg'])
It would be a bit more performant as we wouldn't have to do the split every time
The issue with using an array is that it'd bust the react cache at each re-render when used in an inline way
Using arrays instead of strings has 2 main drawbacks though:
less easy to manipulate with react cache (dependency array in useMemo),
it doesn't add that much values ("It would be a bit more performant" this would be false as we do a lot of transformations & validations afterwards anyway)
But we could use this to add stronger types, like Breakpoints | Breakpoints[]. But as all breakpoints are customizable (even the default ones are overridable), we can't just provide a fixed list of breakpoints.
Maybe something like this would be enough?
useBreakpoint<constBextendsstring|string[]=Breakpoints|Breakpoints[]>(breakpoint: B){…}// Same for only
But there would be no guarantee that it'll match those custom breakpoints (except by manually setting those. Maybe that's enough?)
At the moment, we can do
useBreakpoint('md lg')
. Instead we should supportuseBreakpoint(['md', 'lg'])
It would be a bit more performant as we wouldn't have to do the split every time
The issue with using an array is that it'd bust the react cache at each re-render when used in an inline way
react-responsive/packages/react-responsive/src/useBreakpoint.ts
Line 13 in c624933
The text was updated successfully, but these errors were encountered: