Skip to content

Instantly share code, notes, and snippets.

@webmasterdevlin
Last active March 13, 2019 23:48
Show Gist options
  • Save webmasterdevlin/6b85b84aad8d83f4d3cc21db8bb56548 to your computer and use it in GitHub Desktop.
Save webmasterdevlin/6b85b84aad8d83f4d3cc21db8bb56548 to your computer and use it in GitHub Desktop.
Redux Store : src/store/index.js
import { combineReducers, createStore, applyMiddleware } from "redux";
import { heroReducer } from "./hero/hero-reducer";
import { villainReducer } from "./villain/villain-reducer";
import thunk from "redux-thunk"; // 3rd-party side-effects library.
import { composeWithDevTools } from "redux-devtools-extension"; // Redux devtools for time travel debugging.
/*
Merge all your reducers here. Name it rootReducer.
*/
const rootReducer = combineReducers({
heroState: heroReducer,
villainState: villainReducer
});
/*
This is the store. In Redux, there's only one store. Also known as single source of thruth.
*/
export const store = createStore(
rootReducer, // Put your rootReducer here
composeWithDevTools(applyMiddleware(thunk)) // Making thunk as middleware
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment