if (action.type === PERSIST) {
//...
action.register(config.key)
getStoredState(config).then(
restoredState => {
//...
_rehydrate(migratedState)
// 아래는 persistReducer 코드의 일부분입니다.
export default function persistReducer<State: Object, Action: Object>(
config: PersistConfig, // 첫 번째 인자는 config
baseReducer: (State, Action) => State // 두 번째인자는 Reducer입니다.
): (State, Action) => State & PersistPartial {
//...
return (state: State, action: Action) => {
//...
const rootReducer = combineReducers({
counterReducer: persistReducer(counterPersistConfig, counterReducer)
});
ReactDOM.render(
<Provider store={store}>
<PersistGate loading={<Loading />} persistor={persistor}>
<App />
</PersistGate>
</Provider>,
document.getElementById("root")
const store = createStore(rootReducer);
const persistor = persistStore(store);
render() {
//...
return this.state.bootstrapped ? this.props.children : this.props.loading
}
const counterPersistConfig = {
key: "counter",
storage: storage
};
const rootReducer = combineReducers({
counterReducer: persistReducer(counterPersistConfig, counterReducer)
});
axios.defaults.adapter = require('axios/lib/adapters/xhr')
mock.onPost("http://localhost:3333/").reply(function (config) {
return { message: 'test' }
});
if (data && !utils.isStream(data)) {
if (Buffer.isBuffer(data)) {
// Nothing to do...
} else if (utils.isArrayBuffer(data)) {
data = Buffer.from(new Uint8Array(data));
} else if (utils.isString(data)) {
data = Buffer.from(data, 'utf-8');
} else {
return reject(createError(
axios.defaults.adapter = require('axios/lib/adapters/http')