-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
executable file
·36 lines (29 loc) · 916 Bytes
/
index.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
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, applyMiddleware, compose } from 'redux'
import { configureTracker, logActions } from './util/logger'
import Counter from './components/Counter'
import counter from './reducers'
function devTools () {
return typeof window === 'object' && typeof window.devToolsExtension !== 'undefined' ? window.devToolsExtension() : f => f
}
// setup TrackJS as the logger
configureTracker()
let initialState = 5
const store = createStore(counter, initialState, compose(
applyMiddleware(logActions()),
devTools()
))
const rootEl = document.getElementById('root')
function render () {
ReactDOM.render(
<Counter
value={store.getState()}
onIncrement={() => store.dispatch({ type: 'INCREMENT' })}
onDecrement={() => store.dispatch({ type: 'DECREMENT' })}
/>,
rootEl
)
}
render()
store.subscribe(render)