Replace Reselect example with a more realistic one #4804
Merged
+17
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
name: 📝 Documentation Fix
about: Proposing a more realistic example for Reselect usage
What docs page needs to be fixed?
Original Example
In typical Reselect usage, you write your top-level "input selectors" as plain functions, and use
createSelector
to create memoized selectors that calculate derived values:Note that the second time we called
selectResult
, the "output selector" didn't execute. Because the results ofselectA1
andselectB
were the same as the first call,selectResult
was able to return the memoized result from the first call.Newly proposed example
In typical Reselect usage, you write your top-level "input selectors" as simple functions that just return values nested somewhere inside the state object. Then, you use
createSelector
to create memoized selectors that take one or more of these values as input and produce new derived values:Note that the second time we called
selectTodosForCurrentUser
, the "output selector" didn't execute. Because the results ofselectTodos
andselectCurrentUser
were the same as the first call,selectTodosForCurrentUser
was able to return the memoized result from the first call.