From 2aa0446780c68bdc92e6e44a631b1a2c579dc8ac Mon Sep 17 00:00:00 2001 From: JeongBin0227 <45503248+JeongBin0227@users.noreply.github.com> Date: Wed, 6 Jan 2021 23:37:34 +0900 Subject: [PATCH] =?UTF-8?q?[#1]=20feat=20:=20rootRedux=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rootAction 생성 - rootActionTypes 생성 - rootReducer 생성 - rootSelectort 생성 --- src/data/configureStore.tsx | 32 ++++++++++++++++++++++++++++++++ src/data/rootActionTypes.tsx | 1 + src/data/rootActions.tsx | 4 ++++ src/data/rootReducer.tsx | 11 +++++++++++ src/data/rootSelectors.tsx | 3 +++ 5 files changed, 51 insertions(+) create mode 100644 src/data/configureStore.tsx create mode 100644 src/data/rootActionTypes.tsx create mode 100644 src/data/rootActions.tsx create mode 100644 src/data/rootReducer.tsx create mode 100644 src/data/rootSelectors.tsx diff --git a/src/data/configureStore.tsx b/src/data/configureStore.tsx new file mode 100644 index 0000000..dbee315 --- /dev/null +++ b/src/data/configureStore.tsx @@ -0,0 +1,32 @@ +import { applyMiddleware, compose, createStore } from 'redux'; +import { createBrowserHistory } from 'history'; +import { routerMiddleware } from 'connected-react-router'; +import { createRootReducer } from './rootReducer'; + +const history = createBrowserHistory(); + +const rootReducer = createRootReducer(history); + +declare global { + interface Window { + __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose; + } +} + +const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; + + +export default function configureStore() { + const store = createStore( + rootReducer, + compose( + applyMiddleware(routerMiddleware(history)), + composeEnhancers + ) + ); + + return { + store, + history, + }; +} diff --git a/src/data/rootActionTypes.tsx b/src/data/rootActionTypes.tsx new file mode 100644 index 0000000..7fb93d9 --- /dev/null +++ b/src/data/rootActionTypes.tsx @@ -0,0 +1 @@ +export * from './users/actionTypes' diff --git a/src/data/rootActions.tsx b/src/data/rootActions.tsx new file mode 100644 index 0000000..edfd7fe --- /dev/null +++ b/src/data/rootActions.tsx @@ -0,0 +1,4 @@ +import { routerActions as router } from 'connected-react-router' +import * as user from './users/actions' + +export { router, user } diff --git a/src/data/rootReducer.tsx b/src/data/rootReducer.tsx new file mode 100644 index 0000000..15a9c49 --- /dev/null +++ b/src/data/rootReducer.tsx @@ -0,0 +1,11 @@ +import { connectRouter } from 'connected-react-router' +import { combineReducers } from 'redux' +import user from './users/reducers' + +const createRootReducer = (history) => + combineReducers({ + router: connectRouter(history), + user, + }) + +export { createRootReducer } diff --git a/src/data/rootSelectors.tsx b/src/data/rootSelectors.tsx new file mode 100644 index 0000000..02b1651 --- /dev/null +++ b/src/data/rootSelectors.tsx @@ -0,0 +1,3 @@ +import * as users from './users/selectors' + +export { users }