0

I'm new to React Native and Redux. I'm trying to replace an access token so that any offline request can be sent as soon as user signing in. I'm storing the new token using AsyncStorage. What would be the correct way to update the token (and avoiding "a state mutation was deetected")?

const customeOfflineConfig: Config = {
  ...offlineConfig,
 
  retry: (action, retries) => {
    console.log('retry', action, retries);
    // interval between _retries
    return 10000;
  },
  discard: (error: any, action, retries) => {

    if (!('status' in error)) {
      return true;
    }
    const state = store.getState();
    if(error.status === 401) {
      getAccessToken().then(token => {
        action.meta.offline.effect.headers.Authorization = `Bearer ${token}`; // wrong
      })
     
Dan
  • 173
  • 2
  • 18

0 Answers0