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
Queries are not reloaded when the environment changes #14
Comments
Even the naive code that recreates the router every time the environment changes still doesn't pickup the new environment which is even more concerning:
Reproduction: https://github.com/steinybot/react-router-relay/blob/bug/stale-environment-2/examples/todo/src/MyRouter.tsx I printed a unique id for each environment and you can clearly see here that when the entry point root rerenders it has a query with a stale environment: |
This is a bit strange. |
The first issue that I have noticed is that I haven't tracked down exactly why What I haven't figured out yet is why |
This will be fixed in remix-run/react-router#11301. The example will still be wrong. You must create a new router when the environment changes. The router state must go back to A workaround is to put a key on the
|
I just spent about half a day trying to figure out why the workaround wasn't working. That'll be why the original example in the readme uses a ref and does not update it purely in a useEffect like it really ought to. |
So the example used a ref just to avoid recreating the routes and recreating the router on environment changes. It sounds like we do always need to do that though. In our production system it looks like we do recreate the router when the environment changes. Definitely open to changing the readme to better outline changing the environment.
I'm not sure I follow this part, |
The example code in the README for how to change the environment does not work.
The queries are not reloaded and relay will print the following warning:
See a reproduction here: https://github.com/steinybot/react-router-relay/blob/bug/stale-environment/examples/todo/src/MyRouter.tsx
The text was updated successfully, but these errors were encountered: