-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
57 lines (42 loc) · 1.26 KB
/
main.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
55
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import { createStore, applyMiddleware,combineReducers } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
import {TomModule} from './src/components/index.js'
import * as ComponentModules from './src/components'
let Apples = TomModule.container;
const componentReducers = ()=>{
let reducers = {}
Object.entries(ComponentModules).map(([name,components])=>{
if(components.reducer) reducers[name.split('Module')[0]] = components.reducer;
})
return combineReducers(reducers);
}
const store = createStore(componentReducers(), composeWithDevTools());
const render = Component => {
ReactDOM.render(
<AppContainer>
<Component/>
</AppContainer>,
document.body
)
}
class MainContent extends Component {
constructor(){
super();
}
render(){
return <Provider store={store}>
<Apples />
</Provider>
}
}
MainContent.propTypes = {
}
render(MainContent);
if(module.hot){
module.hot.accept(null, () => { render(MainContent) })
}