-
Notifications
You must be signed in to change notification settings - Fork 62
Description
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?