-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tsx
More file actions
19 lines (16 loc) · 697 Bytes
/
main.tsx
File metadata and controls
19 lines (16 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as StyleContext from 'isomorphic-style-loader/StyleContext';
import App from '~/client/App';
import {getInitialStateAndClear} from '~/ssr/data-cache';
import {addStateContext} from '~/ssr/StateContext';
const insertCss = (...styles: any[]) => {
const removeCss = styles.map(style => style._insertCss());
return () => removeCss.forEach(dispose => dispose());
};
const addStyleContext = (app: JSX.Element) =>
<StyleContext.Provider value={{insertCss}}>{app}</StyleContext.Provider>;
ReactDOM.hydrate(
addStyleContext(addStateContext(<App />, getInitialStateAndClear())),
document.getElementById('root')
);