Parsing error: Identifier 'action' h been declared
来源:5-8 使用 actionCreator 统一创建 action

qq_慕工程2524350
2020-02-23
对照老师的,一模一样啊,不知道问题出在哪里了。。
代码如下:
import React, { Component } from ‘react’;
import ‘antd/dist/antd.css’;
import { Input, Button, List } from ‘antd’;
import store from './store/index.js’
import { getInputChangeAction, getAddItemAction, getDeleteItemAction } from ‘./store/actionCreators5.8’
class TodoList extends Component {
constructor(props) {
super(props);
this.state = store.getState();
this.handleInputChange = this.handleInputChange.bind(this);
this.handleStoreChange = this.handleStoreChange.bind(this);
this.handleBtnClick = this.handleBtnClick.bind(this);
store.subscribe(this.handleStoreChange); //store的内容只要改变,括号中函数就执行。
}
render() {
return (
<div style={{marginTop: ‘10px’, marginLeft: ‘10px’}}>
<Input
value={this.state.inputValue}
placeholder='待办事项’
style={{width: ‘300px’, marginRight: ‘10px’ }}
onChange={this.handleInputChange}
/>
提交
<List
style={{marginTop: ‘10px’, width: ‘300px’}}
bordered
dataSource={this.state.list}
renderItem={(item, index) => (
<List.Item onClick={this.handleItemDelete.bind(this, index)}>
{item}
</List.Item>
)}
/>
)
}
handleInputChange(e) {
const action = getInputChangeAction(e.target.value);
store.dispatch(action);
}
handleStoreChange() {
this.setState(store.getState())
}
handleBtnClick() {
const action = getAddItemAction();
store.dispatch(action);
}
handleItemDelete(index) {
const action = getDeleteItemAction(index);
store.dispatch(action);
}
}
export default TodoList;
1回答
-
Dell
2020-02-25
import { getInputChangeAction, getAddItemAction, getDeleteItemAction } from ‘./store/actionCreators5.8’ 5.8你这个是不是写错了
032020-02-27
相似问题