Skip to content

Instantly share code, notes, and snippets.

@dialguiba
Last active February 5, 2022 05:29
Show Gist options
  • Save dialguiba/d959c7824cd0ed5885b9a648c57a1346 to your computer and use it in GitHub Desktop.
Save dialguiba/d959c7824cd0ed5885b9a648c57a1346 to your computer and use it in GitHub Desktop.
react-store

Create React Store

Packages

  • react-redux
  • react-thunk
  • redux
import { Provider } from "react-redux";
import { AppRouter } from "./router/AppRouter";
import { store } from "./store/store";
export const CalendarApp = () => {
return (
<Provider store={store}>
<AppRouter />
</Provider>
);
};
import { combineReducers } from "redux";
import { authReducer } from "./authReducer";
import { calendarReducer } from "./calendarReducer";
import { uiReducer } from "./uiReducer";
export const rootReducer = combineReducers({
ui: uiReducer,
calendar: calendarReducer,
auth: authReducer,
// TODO: CAlendarReducer
});
import { applyMiddleware, compose, createStore } from "redux";
import thunk from "redux-thunk";
import { rootReducer } from "../reducers/rootReducer";
const composeEnhancers = (typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;
export const store = createStore(rootReducer, composeEnhancers(applyMiddleware(thunk)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment