Currently useStyleProps accesses the BreakpointProvider context to evaluate which user provided responsive size should be used at the current matched breakpoint. However, this means all components that use useStyleProps will rerender if the matched breakpoint changes due to the way React contexts work (re-renders if the context value changes), even if the component doesn't have any responsive styles provided.
๐ค Expected Behavior
Components should only re-render when the matched breakpoint changes AND if they have responsive styles that depend on said breakpoints
๐ฏ Current Behavior
Components always re-render when the matched breakpoint changes
๐ Possible Solution
Unsure, would break the rule of hooks if we conditionally call the useBreakpoint hook.
๐ Bug Report
Currently useStyleProps accesses the BreakpointProvider context to evaluate which user provided responsive size should be used at the current matched breakpoint. However, this means all components that use
useStyleProps
will rerender if the matched breakpoint changes due to the way React contexts work (re-renders if the context value changes), even if the component doesn't have any responsive styles provided.๐ค Expected Behavior
Components should only re-render when the matched breakpoint changes AND if they have responsive styles that depend on said breakpoints
๐ฏ Current Behavior
Components always re-render when the matched breakpoint changes
๐ Possible Solution
Unsure, would break the rule of hooks if we conditionally call the useBreakpoint hook.
๐ Your Environment
๐งข Your Company/Team
RSP