I want to add events to a build in a loop, but why not?
class Lesson extends Component {
/* TODO */
constructor(){
super()
}
alertInfo(lesson,index){
console.log(index+"-"+lesson.title)
}
render(){
const lesson=this.props.lesson
const index=this.props.index
console.log(lesson)
return(
<div >
<h1 onClick={this.alertInfo.bind(this,lesson,index)}>{ lesson.title }</h1>
{ lesson.description }
</div>
)
}
}
class LessonsList extends Component {
/* TODO */
constructor(){
super()
}
info(){
console.log(666)
}
render(){
const lessons = this.props.lessons
console.log(lessons)
return (
<div>
{
lessons.map((item,index)=>
<Lesson lesson={item} key={index} index={index} onClick={()=>{console.log(666)}}/>
)
}
</div>
)
}
}