-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jsx
46 lines (38 loc) · 997 Bytes
/
index.jsx
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
/** @jsx createElement */
import { createElement } from 'react'
import { render } from 'react-dom'
import { Provider, connect } from 'react-redux'
import { createStore } from 'redux'
import { batchedSubscribe } from 'redux-batched-subscribe'
import { composeWithDevTools } from 'redux-devtools-extension'
function App (props) {
return <input type='text' value={props.value} onChange={function (e) { props.update(e.target.value) }} />
}
var ConnectedApp = connect(
function (props) { return props },
{ update: update }
)(App)
var UPDATE = 'update'
function update (payload) {
return {
type: UPDATE,
payload: payload
}
}
function reducer (state, action) {
if (action.type === UPDATE) {
return { value: action.payload }
}
return { value: '' }
}
var store = createStore(
reducer,
composeWithDevTools(
batchedSubscribe((notify) => notify())
)
)
render(
<Provider store={store}>
<ConnectedApp />
</Provider>
, window.document.getElementById('app'))