-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcreateRoot.js
54 lines (47 loc) · 1.36 KB
/
createRoot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const React = require('react')
const ReactDOM = require('react-dom')
const { Provider: ReduxProvider } = require('react-redux')
const { Provider: FelaProvider } = require('react-fela')
const { ConnectedRouter } = require('react-router-redux')
const createBrowserHistory = require('history/createBrowserHistory').default
const h = require('react-hyperscript')
const merge = require('ramda/src/merge')
const Root = require('./Root')
const createStore = require('./createStore')
const { createStyleRenderer } = require('./createStyle')
const createClient = require('./createClient')
module.exports = createRoot
function createRoot (options) {
const {
config,
store: storeOptions,
style: styleOptions,
client: clientOptions,
root: rootOptions,
intl: intlOptions
} = options
const state = { config }
const history = createBrowserHistory()
const client = createClient(clientOptions)
window.client = client
const store = createStore(
merge(
{ state, history, client },
storeOptions
)
)
window.store = store
const styleTheme = styleOptions.theme
const styleRenderer = createStyleRenderer(styleOptions)
const { locale, messagesByLocale } = intlOptions
return (children) => {
return h(Root, {
history,
store,
locale,
messagesByLocale,
styleRenderer,
styleTheme
}, children)
}
}