我如何知道已按下哪个活动详情?
renderPeople() {
if (this.state.teachers != null && this.state.teachers.length >= 1) {
return this.state.teachers.map(teacher => (
<ActivityDetail key={teacher.UID} person={teacher} onPress={() => this.setState({ isTeacherVisible: true })} />
));
}
return null;
}
答案 0 :(得分:0)
您也可以将UID
保存到道具
this.setState({ isTeacherVisible: true, selectedTeacher: teacher.UID })
完整代码:
renderPeople() {
if (this.state.teachers != null && this.state.teachers.length >= 1) {
return this.state.teachers.map(teacher => (
<ActivityDetail key={teacher.UID} person={teacher} onPress={() => this.setState({ isTeacherVisible: true, selectedTeacher: teacher.UID })} />
));
}
return null;
}