React · Junior · Question 58 of 75

How do you pass an argument to a click handler?

{todos.map((t) => <button key={t.id} onClick={() => remove(t.id)}>×</button>)}

Explanation

onClick expects a function. remove(t.id) would run during render and pass its return value as the handler.

Further reading

Problem with a question

React · Junior · question 58

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz