0

What will be the output?

author
subina kallyani
hard
2
108
function App({ show }) {
const [count, setCount] = React.useState(0);

if (show) {
const [extra, setExtra] = React.useState(100);
}

return <div>{count}</div>;
}
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
    What will be the output? - hooks | EBAT