【发布时间】:2020-11-04 03:59:03
【问题描述】:
我正在尝试对我的组件进行排序
<input type="text" value={props.filters.text} onChange={(e) => {
props.dispatch(setTextFilter(e.target.value));
}} />
{console.log(props.filters.sortBy)}
<select value={props.filters.sortBy} onChange={(e) => {
if (e.target.value === 'date') {
props.dispatch(sortByDate());
} else if (e.target.value === 'amount') {
props.dispatch(sortByAmount());
}
}}>
<option value="amount">Amount</option>
<option value="date">Date</option>
</select>
我在选择标签中有错误。
收到错误A component is changing a controlled input of type text to be uncontrolled
props.filters.sortBy 的值最初是日期。当我尝试从下拉列表中更改它时,会发生错误。
【问题讨论】:
标签: javascript reactjs react-redux