我有一个漂亮的标准样板。基本上,我实施了Redux-Persist和渲染加载屏幕,直到将商店重新水化为止。
store.js
const store = Reactotron.createStore(
reducers,
undefined,
compose(
applyMiddleware(ReduxThunk),
offline({
...offlineConfig,
persistCallback: () => Reactotron.log('HEY LOADED') //<<====How to update rehydrated state in App.js
})
)
);
app.js
import store from './Store';
export default class App extends Component {
state = { rehydrated: false };
...
render() {
if (!this.state.rehydrated) return <Loading />
return (
<Provider store={store}>
<MainNavigator />
</Provider>
)
}
基于上述设置,我可以看到在商店成功补充后的登录。但是我想知道它如何更新app.js的状态?
您可以实现PersistGate
以显示加载屏幕,直到检索到持久状态为止。如这里第二部分所述,https://github.com/rt2zz/redux-persist#basic-usage