mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import './css/site.css';
|
|
import 'bootstrap';
|
|
import * as React from 'react';
|
|
import * as ReactDOM from 'react-dom';
|
|
import { browserHistory, Router } from 'react-router';
|
|
import { Provider } from 'react-redux';
|
|
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;
|
|
const store = configureStore(initialState);
|
|
const history = syncHistoryWithStore(browserHistory, store);
|
|
|
|
// This code starts up the React app when it runs in a browser. It sets up the routing configuration
|
|
// and injects the app into a DOM element.
|
|
ReactDOM.render(
|
|
<Provider store={ store }>
|
|
<Router history={ history } children={ routes } />
|
|
</Provider>,
|
|
document.getElementById('react-app')
|
|
);
|