Add example of isomorphic cookies for #581

This commit is contained in:
SteveSandersonMS
2017-01-16 12:54:44 +00:00
parent f8714e9653
commit 9c9892ab18
5 changed files with 54 additions and 5 deletions

View File

@@ -8,6 +8,15 @@ import { syncHistoryWithStore } from 'react-router-redux';
import routes from './routes';
import configureStore from './configureStore';
import { ApplicationState } from './store';
import cookie from 'react-cookie';
// If the server supplied any edits to cookies, apply them on the client
const cookieDataFromServer = window['cookieData'];
if (cookieDataFromServer) {
Object.getOwnPropertyNames(cookieDataFromServer).forEach(name => {
cookie.save(name, cookieDataFromServer[name]);
});
}
// Get the application-wide store instance, prepopulating with state from the server where available.
const initialState = (window as any).initialReduxState as ApplicationState;