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
Tom2y 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
barry2y ago
Show code??
Tom
Tom2y 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
Want results from more Discord servers?
Add your server