36. React Redux的使用(1) - yiqunkeke/react-jianshu-shangguigu-zty GitHub Wiki
只使用redux
import {createStore} from 'redux'
import reducer from './reducer'
const store = createStore(reducer)
export default store
const defaultState = {
inputValue: '',
list: []
}
export default (state = defaultState, action) => {
return state
}
import React from 'react'
import ReactDOM from 'react-dom'
import TodoList from './TodoList'
ReactDOM.render(TodoList, document.getElementById('root'))
import React, {Component} from 'react'
import stroe from './store'
class TodoList extends Component {
constructor(props) {
super(props)
this.state = store.getState()
}
render() {
reture (
<input value={this.state.inputValue}/>
)
}
}
export default TodoList