Concept
Pass a function to onClick, onChange or onSubmit and React calls it with the event. Handlers usually update state, call a prop callback, or prevent the browser's default action.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Event handlers doing its job.
function DeleteButton({ id, onDelete }: { id: string; onDelete: (id: string) => void }) {
return (
<button
onClick={(event) => {
event.stopPropagation(); // the row behind it has its own click
onDelete(id);
}}
>
Delete
</button>
);
}Writing onClick={onDelete(id)}. That calls the function during render and passes its result as the handler. Pass a function: onClick={() => onDelete(id)}.
Your roadmap puts these before Event handlers, unless you already know them.
Once a session shows you understand Event handlers, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Event handlers.