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
Lastly, it might be worth trying generating the dependency list automatically from styles using the flattened entries approach above, directly inside the hook implementation (breaking change), and adopt if perf doesn't suffer significantly. Not having to supply a dependency array would improve ergonomics by a boatload. Alternatively, we can make this behavior default but allow users to optimize by supplying an optional dependency list.
It would enable calling in arbitrary locations in the tree.
We could use the styles call to add to cache (compartmentalizing it to distinguish between injected vs not), and then useLayoutEffect (eventually useInsertionEffect) in the useStyles to inject to stylesheet.
Unfortunately RFC was rejected: reactjs/rfcs#197
This means usage of the hook API will continue to be rather painful when branching/mapping is involved.
Potential pivot: a component API!
Internally, implemented as:
Nice thing here is dependency analysis becomes automatic, unfortunately doesn't look very performant... Still worth benchmarking though.
Alternatively, a more direct translation:
Lastly, it might be worth trying generating the dependency list automatically from styles using the flattened entries approach above, directly inside the hook implementation (breaking change), and adopt if perf doesn't suffer significantly. Not having to supply a dependency array would improve ergonomics by a boatload. Alternatively, we can make this behavior default but allow users to optimize by supplying an optional dependency list.
https://github.com/lewisl9029/use-styles/blob/master/src/useStyles.js#L172
to
One more idea: Let users specify if they're passing in memoized styles to begin with.
Can also split into dynamic vs static styles props.
The text was updated successfully, but these errors were encountered: