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

Using hooks/context in the context of middleware #146

Open
matt-dalton opened this issue Mar 3, 2022 · 0 comments
Open

Using hooks/context in the context of middleware #146

matt-dalton opened this issue Mar 3, 2022 · 0 comments

Comments

@matt-dalton
Copy link

Use-case
In situations where the server invalidates the user's auth token, we have some custom middleware in our network layer that logs a user out. This seems to be fairly standard practice and the middleware seems like the right place for it.
On logout (either via a button, or the middleware above) we create a new Relay environment to ensure the store is cleared for the next user. Again, this seems to be standard practice.

The problem
When this happens, the environment in the RelayEnvironmentProvider is not automatically updated, so until the user restarts the app anything using the environment from that provider will send data to the old store.

How this impacts the library
I don't see a way round updating this provider via context when logging out. This means we need to be able to update the context from within the middleware.
Is there a way of doing this? Has anyone worked round a similar issue where it's been necessary to update a react component from within the middleware?

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