我在用着react-select。当我从 select 中选择一个确定值时,我遇到了下一个问题
类型错误:无法读取未定义的属性“值”
另外,从减速器获取的值todoList没有显示,我看不到它们。
这是我的代码:
import Select from "react-select";
import "./styles.css";
import { searchTodos } from "../../actions/ServiceActions";
class SelectedTodo extends Component {
constructor(props) {
super(props);
this.state = {
selectedTodo: ""
};
this.handleChange = this.handleChange.bind(this);
}
bringTodos = () => {
//WHEN I'M EXECUTING THESE CODE LINES I CAN'T SEE TODOS VALUES
return this.props.todoList.map(todo => {
return (
<option key={todo._id} value={todo._id}>
{todo.name}
</option>
);
});
};
handleChange = e => {
this.setState({ selectedTodo: e.target.value });
}; …Run Code Online (Sandbox Code Playgroud)