Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FetchyeProvider): correct stale data bug #47

Merged
merged 1 commit into from
Jul 9, 2021
Merged

Conversation

code-forger
Copy link
Member

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • My changes are in sync with the code style of this project.
  • There aren't any other open Pull Requests for the same issue/update.
  • These changes should be applied to a maintenance branch.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using Fetchye?

There should be no impact to developers as there is no change to an api.

Ensure the selector properly causes a render when the key changes
@code-forger code-forger requested review from a team as code owners July 9, 2021 16:16
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 9, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f5423ce:

Sandbox Source
quick-install Configuration
fetchye-provider-install Configuration
fetchye-redux-provider-install Configuration
nextjs-fetchye-ssr Configuration

@JAdshead JAdshead merged commit 2ff8c5a into main Jul 9, 2021
@JAdshead JAdshead deleted the fix/stale-data branch July 9, 2021 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants