Skip to content
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

Will useMemo replace reselect? #386

Closed
coryhouse opened this Issue Dec 15, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@coryhouse
Copy link

coryhouse commented Dec 15, 2018

Is there anything reselect offers that useMemo can't handle?

@vinnymac

This comment has been minimized.

Copy link

vinnymac commented Dec 15, 2018

With only a cursory glance, I would assume that useMemo cannot replace reselect simply because useMemo is a hook and therefore will only work with functional components. While reselect works with any type of component.

As far as I know the original intent was to couple reselect with react-redux. Seeing as they plan on adding support for some kind of useRedux like functionality in react-redux I'd figure that could be coupled with useMemo eventually. I am pretty sure to get a real answer to your question we will have to wait to see what it is exactly react-redux creates in regards to a hook, and whether or not that works well with useMemo.

With that said, reselect can be used anywhere, as it has no dependencies. So if it was necessary to use with a theoretical new hook instead of connect(), it may be able to be repurposed for that use case.

@markerikson

This comment has been minimized.

Copy link
Contributor

markerikson commented Dec 15, 2018

Reselect is indeed useful anywhere, and can be used totally independent of Redux. Really, its competition is libs like memoize-one, not useMemo().

For Redux usage, we recommend using selectors anywhere you access the Redux state tree, not just in mapState functions. That includes thunks, sagas, middleware, and so on. See my post Idiomatic Redux: Using Reselect Selectors for Encapsulation and Performance for more details.

@coryhouse

This comment has been minimized.

Copy link
Author

coryhouse commented Dec 15, 2018

Ha, I dunno what I was thinking. I know Hooks only work in React components. Sigh. Thanks for your patience and the excellent response guys! 👍

Closing. :)

@coryhouse coryhouse closed this Dec 15, 2018

@enoh-barbu

This comment has been minimized.

Copy link

enoh-barbu commented Apr 13, 2019

But in terms of using it within react apps, will there be any reasons for not replacing it with memo hooks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.