Might not be related but just in case anyone has a similar situation as me:
I wanted to reset part of my redux store on every app init.
For example, I store the state for my settingsModal component (boolean) being open or closed inside my redux store and it gets persisted to the device.
If the app closes with the state set to true, the next time they open the app it will rehydrate with the open state which I was trying to prevent.
What I ended up doing was simply adding these pieces of state to the blacklist
in the persist config as shown in the docs here: https://github.com/rt2zz/redux-persist#blacklist--whitelist
import {createStore} from 'redux';
import {persistStore, persistReducer} from 'redux-persist';
import AsyncStorage from '@react-native-community/async-storage';
import reducer from './reducer';
const persistConfig = {
key: 'root',
storage: AsyncStorage,
blacklist: ['settingsOpen'], // <-- can add other pieces of state here
};
const persistedReducer = persistReducer(persistConfig, reducer);
export const store = createStore(persistedReducer);
export const persistor = persistStore(store);
My initial state for the store
const initialState = {
settingsOpen: false,
// ...rest of my init state here
};
So now my settings modal will never be left in the open state when the app starts!