Created
March 20, 2019 09:03
-
-
Save kopax/48f367f62d05b2d6d3373d7e5456a460 to your computer and use it in GitHub Desktop.
This file is use instead of https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/createAdminStore.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default ({ | |
dataProvider, | |
history, | |
customReducers = {}, | |
authProvider = null, | |
customSagas = [], | |
i18nProvider = defaultI18nProvider, | |
initialState, | |
locale = 'en', | |
}) => { | |
const messages = i18nProvider(locale); | |
const appReducer = createAppReducer(customReducers, locale, messages); | |
const persistedReducer = persistReducer(persistConfig, appReducer); | |
const resettableAppReducer = (state, action) => | |
persistedReducer(action.type !== USER_LOGOUT ? state : undefined, action); | |
const saga = function* rootSaga() { | |
yield all( | |
[ | |
adminSaga(dataProvider, authProvider, i18nProvider), | |
...customSagas, | |
].map(fork) | |
); | |
}; | |
const sagaMiddleware = createSagaMiddleware(); | |
const typedWindow = window; | |
const store = createStore( | |
resettableAppReducer, | |
initialState, | |
compose( | |
applyMiddleware( | |
sagaMiddleware, | |
formMiddleware, | |
routerMiddleware(history) | |
), | |
typeof typedWindow !== 'undefined' && | |
typedWindow.__REDUX_DEVTOOLS_EXTENSION__ | |
? typedWindow.__REDUX_DEVTOOLS_EXTENSION__() | |
: f => f | |
) | |
); | |
sagaMiddleware.run(saga); | |
window.persistor = persistStore(store); | |
return store; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment