我目前正在建立一個搜索欄,反應原生和redux但無法通過我的道具可以用文本輸入過濾的格式。React Native無法過濾道具
onInput(text) {
this.setState({
text,
});
/* Search after user stop typing */
clearTimeout(this.inputDelay);
this.inputDelay = setTimeout(() => {
this.getResult(text);
}, 1000);
}
getResult(text) {
if (text.length > 0) {
const { entitiesList } = this.props;
const { dataSource } = this.state;
console.log(this.props.entitiesList); // returns object containing an array
const reg = new RegExp(text, 'i');
const entities = entitiesList.filter((entity) => {
return reg.test(entity.fullName);
});
this.setState({
dataSource: dataSource.cloneWithRows(entities),
});
}
Unhandled JS Exception: _this3.props.entitiesList.filter is not a function
被拋出。 This.props.entitiesList確實返回一個對象,所以我不知道我錯了。
{ performances:
[ { _id: '5893b419d2b38b7122dc24f6',
fullName: 'Brett Monroe',
Z3_performance_Id: '696395',
A_relationship_Place: '1.',
N_event_Division: 'Varsity',
F_performance_Mark: '19.05',
C_athlete_Id: '273452',
},
{...},
{...}
]
}
任何提示/指針讚賞!
可以顯示的'this.props.entitiesList'在控制檯打印的價值? –
{演出: [{_id: '5893b419d2b38b7122dc24f6', L_section_Num: '1', N_impl_Division:空, 全名: '佈雷特門羅', Z3_performance_Id: '696395', A_relationship_Place: '1', N_event_Division : '隊打', F_performance_Mark:'11 .05a」, C_athlete_Id: 'A5273452', }, } .. – Chris