import React, {useState} from "react"; function Todo({todo,index,removeTodo}){ return( <div className="todo"> {todo.text} <div> <button onClick={() => removeTodo(index)} > Remove </button> </div> </div> ); } export default Todo;
Can someone explain why I need to put the () => before calling the function?
take a look at this post: Correct use of arrow functions in React
Should be helpful. Be sure to reference the answer, not the question in the link above.
1.4m articles
1.4m replys
5 comments
57.0k users