首页 > 解决方案 > 状态获取不保存刷新反应本机博览会

问题描述

当我的应用程序刷新时,它不会保存状态,但是当我创建另一个习惯时,即保存状态,并且我想在更新习惯或状态的任何部分发生更改时保存状态:

export const rootReducer = combineReducers({
        habitListReducer,
        progressRefreshReducer,
        currentDateReducer,
        statisticsReducer,
        productiveDayReducer,
        habitCategoryReducer,
        habitsColorReducer,
    })
    
    
    
    
    
    const persistConfig = {
        key: "root",
        storage: AsyncStorage,
    }
    const persistedReducer = persistReducer(persistConfig, rootReducer)
    
    const store = createStore(persistedReducer)
    const persistedStore = persistStore(store)
    
    export default function App() {
        return (
            <Provider store={store}>
                <PersistGate persistor={persistedStore} loading={null}>
                    <NavigationContainer>
                        <BottomTab />
                    </NavigationContainer>
                </PersistGate>
            </Provider>
        )
    }

标签: reactjsreact-nativereact-reduxexporedux-persist

解决方案


推荐阅读