mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Add example of isomorphic cookies for #581
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user