Skip to content

Correct way to share a memoized calculation derived from multiple useQuerys? #8282

Closed Answered by TkDodo
collinosh asked this question in Q&A
Discussion options

You must be logged in to vote

even if across multiple components/render cycles

render cycles yes, components not. Every component gets their own “observer”, so it runs at least once per component.

If not, how can I memoize the calculated value while ensuring the latest query data, to be shared by various components

by memoizing the combine function by its inputs, outside of React. reselect is a library that does this well, or memoize-one.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@collinosh
Comment options

@collinosh
Comment options

@TkDodo
Comment options

@collinosh
Comment options

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