feat(docs): risks of omitting useStore selector #1126
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.
From issue #1122 and a conversation with @crutchcorn, omitting the selector prop of the useStore hook will result in unnecessary re-renders.
The interface of useStore shows it as an optional prop, and while the hook will work without the prop, it is not the recommended approach.
I've searched the Docs for references to this, and the only documentation relating to this hook was under
Reactivity
ofbasic concepts
. However, it does not highlight the risks of omitting selector.The only other references to this hook I found in the documentation were examples demonstrating the use of
useStore
however, none of them highlight this potential pitfall.This PR adds clarification of useStore and examples of correct use.