fix(FetchyeProvider): correct stale data bug #47
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.
This PR implements the same fix as PR46 but for FetchyeProvider
Description
Ensure the effect in the default selector properly causes a re-render when the key changes.
Motivation and Context
Without this change, when 'returning' to data that is already loaded in the cache, the data returned by 'useFetchye' ends up 'one render behind'.
This fix ensures that a change in the key results in an additional render to keep the value up to date.
How Has This Been Tested?
A Unit test has been created that would fail for the old code, which passes for the new code
Using fetchye as part of a One App module, I have recreated this issue using a list of data where selecting an item causes a call to useFetchye in a separate module. Without this fix, when navigating back to a previously visited item, the second module ends up one click behind. With this fix the second module always shows the correct item.
No existing unit tests failed.
Types of Changes
Checklist:
What is the Impact to Developers Using Fetchye?
There should be no impact to developers as there is no change to an api.