[feature] Add useDenormalized() hook selector #134
Merged
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.
Motivation
The goal is to make useDenormalized() the way useCache() selects data - removing the automatic drilling into results to find the entity inside.
schema:
Before
After
Before changing useCache(), we will add this new selector hook and compose it with the 'drill in' behavior to achieve backwards compatible results. While mostly this should be an unnoticed change, we do export the useDenormalized() for those who wish to use it.
Solution
The 'drill in' is now basically all
useSchemaSelect()
does, and it callsuseDenormalized()
first to get the initial stuff. Splitting this up now to provide an elegant migration path before we deprecate the old method. 3.0 will use the new method in the normal names, while still providing the old selector in deprecated hooks (so people can just rename for migration). 3.1 will then remove the legacy hooks.Note
Will add useCacheNew() and useResourceNew() in followup PR