Complete the code to create a simple reusable button component.
function Button({ label }) {
return <button>[1];</button>;
}The label prop is used to display the button text inside the button element.
Complete the code to pass a click handler to the reusable button component.
function Button({ label, [1] }) {
return <button onClick={handleClick}>{label}</button>;
}The component expects a prop named handleClick to be used as the click event handler.
Fix the error in the reusable component by completing the missing import statement.
import React from '[1]'; function Button({ label }) { return <button>{label}</button>; }
React components need to import from the react package to work properly.
Fill both blanks to create a reusable component that accepts children and a className prop.
function Card({ [1], [2] }) {
return <div className={className}>{children}</div>;
}The component uses children to render nested content and className for styling.
Fill all three blanks to create a reusable list component that maps items to list elements with keys.
function List({ items }) {
return (
<ul>
{items.map(([1], [2]) => (
<li key=[3]>[1]</li>
))}
</ul>
);
}The map function uses item and index as parameters, and the index is used as the key for each list item.