Skip to content

Instantly share code, notes, and snippets.

@imran-ib
Created October 29, 2018 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imran-ib/2a66beb2bd079d5ce20b48807179ab1c to your computer and use it in GitHub Desktop.
Save imran-ib/2a66beb2bd079d5ce20b48807179ab1c to your computer and use it in GitHub Desktop.
redux store
import { combineReducers } from "redux";
import testReducer from "./testReducer";
import { reducer as formReducer } from "redux-form";
import { reducer as toastrReducer } from "react-redux-toastr";
const rootReducer = combineReducers({
test: testReducer,
form: formReducer,
toastr: toastrReducer
});
export default rootReducer;
import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import rootReducer from "../../app/reducers/rootReducer";
import thunk from "redux-thunk";
export const configureStore = preloadedState => {
const middleWare = [thunk];
const middleWareEnahcer = applyMiddleware(...middleWare);
const storeEnhancer = [middleWareEnahcer];
const composeEnahncer = composeWithDevTools(...storeEnhancer);
const store = createStore(rootReducer, preloadedState, composeEnahncer);
return store;
};
//in Index.js
import { configureStore } from "./location";
const store = configureStore(); // pass this to Provider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment