Complete the code to create a React functional component that returns a simple greeting.
function Greeting() {
return <h1>[1]</h1>;
}In React JSX, text inside tags is written directly without quotes.
Complete the code to update state using React's useState hook.
const [count, setCount] = React.useState(0); function increment() { setCount([1]); }
React state updates should use new values, not mutate existing ones.
Fix the error in the React event handler to correctly log the button click.
<button onClick=[1]>Click me</button>Event handlers need a function, so wrap the log in an arrow function.
Fill both blanks to create a React component that renders a list from an array.
function ItemList() {
const items = ['apple', 'banana', 'cherry'];
return (
<ul>
{items.[1](item => <li key={item}>[2]</li>)}
</ul>
);
}Use map to create elements from an array and display the item text.
Fill all three blanks to create a controlled input component in React.
function NameInput() {
const [name, setName] = React.useState('');
return (
<input
type="text"
value=[1]
onChange={e => [2](e.target.[3])}
aria-label="Name input"
/>
);
}The input's value is controlled by state, and onChange updates that state with the input's current value.
