React · Junior · Question 73 of 75

Why doesn't clicking <MyButton onClick={save} /> call save?

function MyButton({ label }) {
  return <button>{label}</button>;
}

Explanation

Only built-in DOM elements turn onClick into a listener. The component must accept the prop and forward it: <button onClick={onClick}>.

Further reading

Problem with a question

React · Junior · question 73

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