Files
imexmobile/redux/store.js
2025-10-03 12:06:24 -07:00

37 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { applyMiddleware, compose, createStore } from "redux";
import { persistStore } from "redux-persist";
import { createLogger } from "redux-logger";
import rootSaga from "./root.saga";
import rootReducer from "./root.reducer";
const createSagaMiddleware = require('redux-saga').default;
const sagaMiddleWare = createSagaMiddleware();
const middlewares = [sagaMiddleWare];
if (process.env.NODE_ENV === "development") {
middlewares.push(
createLogger({
collapsed: true,
})
);
}
//Add in for React Native Debugger.
const composeEnhancers =
typeof window === "object" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extensions options like name, actionsBlacklist, actionsCreators, serialize...
})
: compose;
const enhancer = composeEnhancers(
applyMiddleware(...middlewares)
// other store enhancers if any
);
export const store = createStore(rootReducer, enhancer);
sagaMiddleWare.run(rootSaga);
export const persistor = persistStore(store);
export default { store };