Skip to content

Best approach for selectors #387

Answered by dai-shi
clenemt asked this question in Q&A
May 11, 2021 · 2 comments · 10 replies
Discussion options

You must be logged in to vote

https://github.com/pmndrs/zustand#memoizing-selectors

Defining selectors outside component will be most preferable. In the future version (v4), this style will be more performant than inline selectors. If selectors depend on props, useCallback would be recommended. That said, it's rather unopinionated, so either way is fine.

(In this context, I assume the selector function is lightweight.)

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
7 replies
@clenemt
Comment options

@dai-shi
Comment options

@dsacramone
Comment options

@maxwaiyaki
Comment options

@dai-shi
Comment options

Answer selected by clenemt
Comment options

You must be logged in to vote
3 replies
@dai-shi
Comment options

@timeturnback
Comment options

@dai-shi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants