Rendered more hooks than during the previous render



works fine until this code is commented, as I put this button under condition this error comes up, and without the button all works fine,

using one useState hook with two keys for state object and no UseEffect,
tried putting useState definition up to the code

Hi!

I’d love to see implementation of Button component, but as of now, I think you should be passing a callback to the onClick prop, instead of a function call.

1 Like

Sure I can make you see the implentation too,
its about getting a person signedUp from anyother web,
and the api gives a token that gets to the verify button ,and the success match , makes him go to the dashboard,

but what will be the difference using it with or without callback?
will callback make this handle run at the last as its nature, ?

navigate(‘route’) is being called immediately when Button is rendered and what you’re aiming for, probably, is to navigate user to route once the button is clicked. Therefore, callback is needed in that case. If you wanted to navigate user to certain route, without explicitly clicking on button, you could use the useEffect hook to take care of that.
Hope this helps!

I got it, It is a blunder I forgot that there is a navigate in it,
just saw an error having word “state” in it,
i presumed i am setting a state there onClick as before,
but thanks for the time and interest bro, stay blessed <3

1 Like