For endpoints requiring authentication, if the session (stored in cookies) expired, I want to navigate to the login screen for the user to re-authenticate.
Since this logic is applicable to all endpoints, the ideal place to handle this would be in the fetch method that is used by all endpoints:
const get = (...) => axios(...).catch((e) => {
if (((e || {}).response || {}).status === 401) {
// navigate to login screen
}
throw e;
});
With Redux integration, we can simply dispatch the navigation action in the error handler.
However, since
react-navigation
is dropping support for Redux, there will no longer be a way to achieve this, without having to add the above code for every endpoint used in the component, or pass
props.navigation
as argument to every api call (which is not possible if the api call is performed at global level, Eg. in
AppState
event listener or redux-persist
persistStore
call back).
Hence, continual support of Redux integration might be useful to support use cases like above.