, .
, , ( ), Redux, .
Node.js Redux 1.0.0 ES6:
const initialState = {
post: getBlogPostById(id);
};
const reducer = combineReducers(reducers);
const store = createStore(reducer, initialState);
const stateString = JSON.stringify(initialState);
const appString = React.renderToString(
<Provider store={store}>
{() => <App/>}
</Provider>
);
, , appString, stateString, , . Handlebars, ,
<body>
<div id="app">{{{appString}}}</div>
<script>window.INITIAL_STATE = {{{stateString}}}</script>
<script src="/app.js"></script>
</body>
app.js - JS-, , stateString, Redux . , " " DOM, , . , JS- :
const reducer = combineReducers(reducers);
const store = createStore(reducer, window.INITIAL_STATE);
React.render(
<Provider store={store}>
{() => <App/>}
</Provider>,
document.getElementById('app')
);
, , , . React " ", - JSON. , YMMV, ...