Cannot use `useState` inside of callback?

I'm getting this error even though im using it inside a function that returns JSX.Element... No errors in my dev environment, only the vercel linter is saying it fails to compile
4 Replies
Tom
Tom16mo ago
in general hooks need to be called at the top level of a function and cant be called conditionally (other than the brand new use() hook which theyre still working on
barry
barry16mo ago
Show code??
Tom
Tom16mo ago
so you cant call useState() inside a callback
AdmiralGeneralAladeen
ah yep must be because of the conditionals I guess if I break them out into components it should work