我正在使用一个交给我们的应用程序,这个应用程序相当大,而且对于React Native来说我是一个新手。
我不确定重置会解决它。但我想我以某种方式污染了我的国家。一切正常,但后来我想重置我的状态,所以我在app.js
componentWillMount() {
let persistore = persistStore(store, null, () => {
this.setState({rehydrated: true})
});
// persistore.purge();
}
所以我取消注释persistore.purge();
。但现在,当我尝试启动它时,我得到了:
未处理的承诺拒绝:TypeError:null不是对象(评估' instanceInfo.pcb')
它不会停止上演。关于我可以尝试做什么的任何想法。到"重置"我做了什么?我已经在git中重置了一个稳定的提交。
答案 0 :(得分:0)
我不明白你的问题重置状态意味着整个商店,即app状态?
如果是,那么
const appReducer = combineReducers({
nav,
listReducer,
movieDetail
});
const initialState = appReducer({}, {});
const rootReducer = (state, action) => {
if(action.type == "RESET_APP_STATE") {
state = undefined
}
return appReducer(state, action);
}
如果你想要特定的状态,即reducer状态相同,但只针对switch
中特定的reducer,我们使用的主要是return undefined