하루의 이슈
11/12
akjfal
2019. 11. 12. 15:42
redux startr kit + redux persist + redux saga
import { combineReducers } from "redux"
import { persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import root from './reducer'
const persistConfig = {
key:'root',
storage,
whitelist: ['state']
}
export default combineReducers({
root: persistReducer(persistConfig, root),
})
import React from "react";
import { configureStore, getDefaultMiddleware } from 'redux-starter-kit'
import { persistStore } from 'redux-persist'
import { Provider } from "react-redux";
import createSagaMiddleware from "redux-saga";
import { PersistGate } from 'redux-persist/integration/react'
import rootReducer from "./reducers";
import rootSaga from "./sagas";
const sagaMiddleware = createSagaMiddleware();
const store = configureStore({
reducer: rootReducer,
middleware: [ sagaMiddleware ]
});
sagaMiddleware.run(rootSaga);
const persistor = persistStore(store);
const ProviderWrapper = ({ children }) => {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
{children}
</PersistGate>
</Provider>
)
};
export default ProviderWrapper
non-serializable value error
https://github.com/rt2zz/redux-persist/issues/988
non-serializable value error · Issue #988 · rt2zz/redux-persist
Hi folks 👋, I just installed the redux-persist in a project still in its early stages and I'm facing this error message in the console as first thing when the page loads. I haven't done muc...
github.com
redux-starter-kit과 같이 사용시 발생
해결 방법 :
const store = configureStore({
reducer: rootReducer,
middleware: [...getDefaultMiddleware(), sagaMiddleware ]
});
이 코드를
const store = configureStore({
reducer: rootReducer,
middleware: [ sagaMiddleware ]
});
이렇게 코치기 ...getDefaultMiddleware() 삭제