|
1 |
| -import { compose, createStore, applyMiddleware, combineReducers } from 'redux'; |
| 1 | +import { createStore } from 'redux'; |
| 2 | +import helloWorldReducer from '../reducers/helloWorldReducer'; |
2 | 3 |
|
3 |
| -// See |
4 |
| -// https://github.com/gaearon/redux-thunk and http://redux.js.org/docs/advanced/AsyncActions.html |
5 |
| -// This is not actually used for this simple example, but you'd probably want to use this |
6 |
| -// once your app has asynchronous actions. |
7 |
| -import thunkMiddleware from 'redux-thunk'; |
| 4 | +const configureStore = (railsProps) => ( |
| 5 | + createStore(helloWorldReducer, railsProps) |
| 6 | +); |
8 | 7 |
|
9 |
| -import reducers from '../reducers'; |
10 |
| -import { initialStates } from '../reducers'; |
11 |
| - |
12 |
| -export default props => { |
13 |
| - // This is how we get initial props Rails into redux. |
14 |
| - const { name } = props; |
15 |
| - const { $$helloWorldState } = initialStates; |
16 |
| - |
17 |
| - // Redux expects to initialize the store using an Object, not an Immutable.Map |
18 |
| - const initialState = { |
19 |
| - $$helloWorldStore: $$helloWorldState.merge({ |
20 |
| - name, |
21 |
| - }), |
22 |
| - }; |
23 |
| - |
24 |
| - const reducer = combineReducers(reducers); |
25 |
| - const composedStore = compose( |
26 |
| - applyMiddleware(thunkMiddleware) |
27 |
| - ); |
28 |
| - const storeCreator = composedStore(createStore); |
29 |
| - const store = storeCreator(reducer, initialState); |
30 |
| - |
31 |
| - return store; |
32 |
| -}; |
| 8 | +export default configureStore; |
0 commit comments