Skip to content

Is it safe to use createSelector in SSR? #617

Closed Answered by markerikson
aleksakojadinovic asked this question in Q&A
Discussion options

You must be logged in to vote

I think that the reference checks are exactly why this shouldn't be an issue. But also I think this is a somewhat mistaken concern (?).

Every SSR request should have an entirely separate Redux store to begin with, because different users may have different data needs + the actual leakage concerns.

If I have a single selector instance, ie const selectTodos = createSelector(.....), it is indeed a shared cache, and using that across different requests could conceptually "share" results in a sense. BUT:

  • Since every Redux store will have a different state reference, selectTodos(store1.getState()) and selectTodos(store2.getState()) will force the selector to recalculate because it's grabbing d…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by aleksakojadinovic
Comment options

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

@aleksakojadinovic
Comment options

@markerikson
Comment options

@aleksakojadinovic
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
2 participants