Skip to content

Commit

Permalink
[#1] feat : rootRedux 생성
Browse files Browse the repository at this point in the history
- rootAction 생성
- rootActionTypes 생성
- rootReducer 생성
- rootSelectort 생성
  • Loading branch information
JeongBin0227 committed Jan 6, 2021
1 parent d03c785 commit 2aa0446
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/data/configureStore.tsx
Original file line number Diff line number Diff line change
@@ -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,
};
}
1 change: 1 addition & 0 deletions src/data/rootActionTypes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './users/actionTypes'
4 changes: 4 additions & 0 deletions src/data/rootActions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { routerActions as router } from 'connected-react-router'
import * as user from './users/actions'

export { router, user }
11 changes: 11 additions & 0 deletions src/data/rootReducer.tsx
Original file line number Diff line number Diff line change
@@ -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 }
3 changes: 3 additions & 0 deletions src/data/rootSelectors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as users from './users/selectors'

export { users }

0 comments on commit 2aa0446

Please sign in to comment.