-
-
Notifications
You must be signed in to change notification settings - Fork 631
/
Copy pathClientReduxApp.jsx
28 lines (24 loc) · 970 Bytes
/
ClientReduxApp.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Top level component for client side.
// Compare this to the ./ServerApp.jsx file which is used for server side rendering.
import React from 'react';
import { combineReducers, applyMiddleware, createStore } from 'redux';
import { Provider } from 'react-redux';
import middleware from 'redux-thunk';
import reducers from '../reducers/reducersIndex';
import HelloWorldContainer from '../components/HelloWorldContainer';
/*
* Export a function that takes the props and returns a ReactComponent.
* This is used for the client rendering hook after the page html is rendered.
* React will see that the state is the same and not do anything.
*
*/
export default (props, railsContext) => {
const combinedReducer = combineReducers(reducers);
props.railsContext = railsContext;
const store = applyMiddleware(middleware)(createStore)(combinedReducer, props);
return (
<Provider store={store}>
<HelloWorldContainer />
</Provider>
);
};