React question detail
How do you pass an event handler to a component?
You can pass event handlers and other functions as props to child components. The functions can be passed to child component as below,
function Button({ onClick }) {
return <button onClick={onClick}>Download</button>;
}
export default function downloadExcel() {
function handleClick() {
alert("Downloaded");
}
return <Button onClick={handleClick}></Button>;
}