Created
October 29, 2018 14:30
-
-
Save imran-ib/2a66beb2bd079d5ce20b48807179ab1c to your computer and use it in GitHub Desktop.
redux store
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
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; |
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
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