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

Compatibility with fetchQuery #25

Open
wasd171 opened this issue Mar 14, 2020 · 0 comments
Open

Compatibility with fetchQuery #25

wasd171 opened this issue Mar 14, 2020 · 0 comments

Comments

@wasd171
Copy link

wasd171 commented Mar 14, 2020

Hi!

I think that this library might not be 100% compatible with a fetchQuery.
Imagine the following setup:

  • There are 2 pages, PageA and PageB which have a QueryA and QueryB connected to them respectively.
  • We are using relay-query-lookup-renderer only to read from the Relay store, data fetching is done independently via fetchQuery.

The user journey is:

  1. Visits PageA. QueryA is fetched on the server, Relay store records are used to hydrate the store on the client. QueryLookupRenderer reads the data from Relay store by being rendered with query={QueryA} and render={({props}) => <ComponentA data={props}/>}
  2. Travels from PageA to PageB.
  • QueryB is fetched via the fetchQuery
  • QueryLookupRenderer is re-rendered with query={QueryB} and render={({props}) => <ComponentB data={props}/>}, data is already in the store
  1. Travels from PageB to PageA
  • QueryA is fetched via the fetchQuery
  • Possible bug - before QueryLookupRenderer is re-rendered with query={QueryA} it actually invokes the render function with props corresponding to QueryA, even though the render itself is still ({props}) => <ComponentB data={props}/> and the query prop is still QueryB
  • QueryLookupRenderer is re-rendered with query={QueryA} and render={({props}) => <ComponentA data={props}/>}

I suppose that it has to do something with QueryA already being present in the Relay store. Recreating a store on every page transition fixes it.

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

No branches or pull requests

1 participant