React Code Reorder Medium +20 XP
Component with Hook
Arrange a functional component with state.
Click lines in the correct order
Available lines4 left
Your order
Click lines above to build your solution.
Show answer and explanation
Answer: function Counter() {
const [count, setCount] = useState(0);
return <div>{count}</div>;
}
Function declaration, then hook inside the body, then the return statement.
Hint: Hooks go before the return.
What this challenge tests
Code Reorder in React: components, hooks.