function App({ show }) {
const [count, setCount] = React.useState(0);
if (show) {
const [extra, setExtra] = React.useState(100);
}
return <div>{count}</div>;
}
0
What will be the output?
subina kallyani
hard
2completed
86
Answer
- Error → Hooks can only be called at the top level of a component.
React relies on hooks being called in the same order on every render. Conditional hooks break this order
Click to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0