New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Benefit? #2
Comments
Oh I see, this is handy with
The version with
Neat! It's a tad spooky magic that all is done for you but it is simpler to read, might introduce this at work to replace the Feel free to close this issue. |
@danstiner exactly, yes! I think the root issue here is that the root README.md doesn't directly mention why you'd want such a thing. It's mentioned in https://github.com/Codecademy/use-selector-with/tree/71d0f0b/packages/use-selector-with#why but that's about it. |
Added a link in #3 but if you think there's more to be done please do post again @danstiner! The explanations are all me and I would love external eyes on how to make them more reasonable sounding. 😄 |
Curious, is there a benefit to
useSelectorWith
like the following:versus just using
useSelector
?Performance wise I think the
useSelector
version would be actually a smidge faster and I don't see any other relevant differences but I could be missing something!Busy this week but sometime I'll try to do a microbenchmark. The
useCallback
insideuseSelectorWith
adds some overhead, probably more than memoizing the selector function would gain, except for maybe very very complex selectors. Fun reading, react perf is tricky: https://kentcdodds.com/blog/usememo-and-usecallbackThe text was updated successfully, but these errors were encountered: