mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-21 21:49:55 +03:00
Add PersistGate
This commit is contained in:
parent
4bf728ea66
commit
f77420c94c
|
@ -1,33 +1,34 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import { Store } from 'redux';
|
||||
import { Persistor } from 'redux-persist';
|
||||
import { PersistGate } from 'redux-persist/integration/react';
|
||||
import configureStore from './store/configureStore';
|
||||
import { CONNECT_REQUEST } from './constants/socketActionTypes';
|
||||
import App from './containers/App';
|
||||
import { StoreState } from './reducers';
|
||||
import { ConnectionOptions, StoreAction } from './actions';
|
||||
import { StoreAction } from './actions';
|
||||
|
||||
interface Props {
|
||||
socketOptions?: ConnectionOptions;
|
||||
}
|
||||
|
||||
class Root extends Component<Props> {
|
||||
class Root extends Component {
|
||||
store?: Store<StoreState, StoreAction>;
|
||||
persistor?: Persistor;
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
this.store = configureStore();
|
||||
this.store.dispatch({
|
||||
const { store, persistor } = configureStore();
|
||||
this.store = store;
|
||||
this.persistor = persistor;
|
||||
store.dispatch({
|
||||
type: CONNECT_REQUEST,
|
||||
});
|
||||
this.forceUpdate();
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.store) return null;
|
||||
const AppAsAny = App as any;
|
||||
return (
|
||||
<Provider store={this.store}>
|
||||
<AppAsAny {...this.props} />
|
||||
<PersistGate loading={null} persistor={this.persistor!}>
|
||||
<App />
|
||||
</PersistGate>
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,6 @@ export default function configureStore() {
|
|||
persistedReducer as any,
|
||||
composeEnhancers(applyMiddleware(exportState, api))
|
||||
);
|
||||
persistStore(store);
|
||||
return store;
|
||||
const persistor = persistStore(store);
|
||||
return { store, persistor };
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user