Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Query component caches lastResult after props are changed and never updates the stored lastResult value, meaning the component will not redraw when updated to the cached result #2857

Closed
Glennrs opened this issue Mar 10, 2019 · 2 comments · Fixed by #2840

Comments

@Glennrs
Copy link
Contributor

Glennrs commented Mar 10, 2019

Repro:

  1. Query component mounts and renders with value X.
  2. Props to query component are changed, meaning lastResult is set to value X.
  3. Value of data query is fetching is changed to Y. Component redraws.
  4. Value of data query is fetching is changed back to X. Component does not redraw as the shallowEquals is true to lastResult (value X), even though lastResult is value Y.

The following Gist has a repro for the issue. You can see that after the Query component has its properties updated, it will set lastResult to true and subsequently always early out when the value is set back to true again (meaning it remains in a state where it renders false).

https://gist.github.com/Glennrs/8051fcac26ec50a8d113cf4e4586769c

The linked to closed PR contains a fix for this issue.

Originally posted by @Glennrs in #2840 (comment)

@hwillson
Copy link
Member

@Glennrs Could you convert your gist into a runnable reproduction? You can use the react-apollo-error-template as a starting point.

@hwillson
Copy link
Member

Disregard @Glennrs - the reproduction in #2887 demonstrates this issue. I'll re-open your PR, and adjust it to add a regression test.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants