Complete the code to pass the id argument to the click handler.
function Button({ id, onClick }) {
return <button onClick={() => onClick([1])}>Click me</button>;
}this which is not defined in functional components.The id is passed as an argument to the onClick handler using an arrow function.
Complete the code to pass both id and name to the handler.
function Item({ id, name, onSelect }) {
return <div onClick={() => onSelect([1], [2])}>{name}</div>;
}The arrow function calls onSelect with both id and name as arguments.
Fix the error in passing the id argument to the handler.
function ListItem({ id, onClick }) {
return <li onClick=[1]>Item</li>;
}Passing onClick({id}) calls the function immediately. Wrapping it in an arrow function () => onClick(id) delays the call until the click.
Fill both blanks to pass id and event to the handler.
function Clickable({ id, onAction }) {
return <button onClick={(event) => onAction([1], [2])}>Press</button>;
}this which is undefined here.The arrow function receives event and calls onAction with id and event as arguments.
Fill all three blanks to pass userId, event, and extra to the handler.
function UserButton({ userId, extra, onUserClick }) {
return <button onClick={(event) => onUserClick([1], [2], [3])}>Click User</button>;
}The arrow function calls onUserClick with userId, the click event, and extra data.