react中使用setState的终极场景
this.setState(prevState => ({
filterData: prevState.data.filter(item =>
(this.state.searchId ? item.id === Number(this.state.searchId) : true) &&
(this.state.searchTitle ? item.title.toLowerCase().includes(this.state.searchTitle.toLowerCase()) : true)
)
}));
漫思