-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
33 lines (32 loc) · 948 Bytes
/
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
import "babel-polyfill"
import React from 'react'
import ReactDOM from 'react-dom'
import createSagaMiddleware from 'redux-saga'
import { createStore, applyMiddleware ,compose} from 'redux'
import rootSaga, { helloSaga } from './sagas'
import Counter from './Counter'
import reducer from './reducers'
const sagaMiddleware = createSagaMiddleware();
const middlewares=[sagaMiddleware];
const store = createStore(
reducer,
compose(
applyMiddleware(...middlewares),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
)
sagaMiddleware.run(rootSaga)
const action = type => store.dispatch({type})
function render() {
ReactDOM.render(
<Counter
value={store.getState()}
onIncrement={() => action('INCREMENT')}
onDecrement={() => action('DECREMENT')}
onIncrementAsync={()=>action('INCREMENT_ASYNC')}
/>,
document.getElementById('root')
)
}
render()
store.subscribe(render)