I've recently started out with reactjs and have been following a tutorial with freeCodeCamp.org. This is my first post here. Let me know if any more info is needed.
I'm receiving this error: Uncaught TypeError: Cannot read property 'handleChange' of undefined despite binding handleChange()
inside the constructor. Here is the snippet:-
class Todo extends Component {
constructor(props) {
super(props);
this.state = { todos: TodoData };
this.handleChange = this.handleChange.bind(this);
}
handleChange(id) {
console.log("Change", id);
}
render() {
const TodoComps = this.state.todos.map(function (item) {
return (
<TodoItem key={item.id} item={item} handleChange={this.handleChange} />
);
});
return <div>{TodoComps}</div>;
}
}
export default Todo;