Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (initialState, history) => {
const middleware = [environment.isDevelopment ? reduxFreeze : null, thunk, routerMiddleware(history), errorToastMiddleware()].filter(Boolean);
const store = createStore(rootReducer(history), initialState, composeWithDevTools(applyMiddleware(...middleware)));
// store.subscribe(() => console.log(store.getState()));
return store;
};
export default function createFinalStore (client, history) {
const middleware = [
routerMiddleware(history),
createClientMiddleware(client),
// loadingBarMiddleware({ promiseTypeSuffixes: ['PENDING', 'SUCCESS', 'FAIL'] })
]
return createStore(reducers, composeWithDevTools(applyMiddleware(...middleware)))
}
import thunk from 'redux-thunk';
import { ThemeProvider } from 'styled-components';
import './index.scss';
import './i18n';
import reducers from './reducers';
import App from './App';
// eslint-disable-next-line import/no-webpack-loader-syntax
const theme = require('sass-extract-loader?{"plugins":["sass-extract-js"]}!./scss/_index.scss');
/* eslint-disable no-underscore-dangle */
// const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
reducers,
composeWithDevTools(
applyMiddleware(thunk),
));
/* eslint-enable */
ReactDOM.render(
,
document.getElementById('root')
);
const clientSide = isBrowser();
const sagaMiddleware = createSagaMiddleware({
context: {
document: clientSide ? document : {}
}
});
const epicMiddleware = createEpicMiddleware({
dependencies: {
window: clientSide ? window : {},
location: clientSide ? window.location : {},
document: clientSide ? document : {}
}
});
const composeEnhancers = composeWithDevTools({
// options like actionSanitizer, stateSanitizer
});
export const createStore = () => {
const store = reduxCreateStore(
rootReducer,
composeEnhancers(applyMiddleware(sagaMiddleware, epicMiddleware))
);
sagaMiddleware.run(rootSaga);
epicMiddleware.run(rootEpic);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./rootReducer', () => {
const nextRootReducer = require('./rootReducer');
store.replaceReducer(nextRootReducer);
});
});
// Apply middleware to proxy store
const middleware = [thunk, logger];
const storeWithMiddleware = applyMiddlewareChrome(store, ...middleware);
store.ready().then(() => {
ReactDOM.render(
,
document.getElementById("root") as HTMLElement
);
});
} else {
const composeEnhancers = composeWithDevTools({});
const store = createStore(
rootReducer,
composeEnhancers(applyMiddleware(thunk))
);
ReactDOM.render(
,
document.getElementById("root") as HTMLElement
);
}
unregister();
export default function createAppStore(
preloadedState: Partial
): Store {
const sagaMiddleware = createSagaMiddleware()
const enhancer = composeWithDevTools(applyMiddleware(sagaMiddleware))
const store = createStore(reducers, preloadedState as StoreState, enhancer)
sagaMiddleware.run(rootSaga)
return store
}
public static createProviderStore(initialState: Partial = {}, history: History = null, isServerSide: boolean = false): ISagaStore {
const sagaMiddleware: SagaMiddleware = createSagaMiddleware();
const middleware: Middleware[] = [
(isProduction || isServerSide) ? null : reduxFreeze,
routerMiddleware(history),
sagaMiddleware,
].filter(Boolean);
const store: any = createStore(
rootReducer(history),
initialState,
composeWithDevTools(
applyMiddleware(...middleware),
),
);
if (isServerSide) {
store.runSaga = sagaMiddleware.run;
store.endSaga = () => store.dispatch(END);
} else {
sagaMiddleware.run(rootSaga);
}
return store;
}
import { applyMiddleware, combineReducers, createStore } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
import thunk from 'redux-thunk';
import userReducer from 'store/reducers/userReducer'
import notesReducer from 'store/reducers/notesReducer'
const allReducers = combineReducers({
user: userReducer,
notes: notesReducer
})
const compose = composeWithDevTools({})
const middleware = compose(
applyMiddleware(thunk)
)
const store = createStore(allReducers, {}, middleware)
export default store