What is wrong with my client component?
Unanswered
Allegheny mound ant posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Allegheny mound antOP
I added the
useEffect()
hook in a client component, and now it throws me the error:Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
![Image](https://cdn.discordapp.com/attachments/1154328326526226462/1154328326744317983/Screenshot_2023-09-21_at_10.06.12.png)
7 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Allegheny mound antOP
I just fetches widgets form the API using React Query, and sets the first widget it received as the current value.
Seems like
useEffect
has an issue with useQuery
?![Image](https://cdn.discordapp.com/attachments/1154328326526226462/1154329209641115648/Screenshot_2023-09-21_at_10.11.15.png)
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Not sure you can do that
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Allegheny mound antOP
Why wouldn't it be possible?
Do you actually use
The code seems to work without it, but I learned to use
useEffect
in Next?The code seems to work without it, but I learned to use
useEffect
from vanilla React.![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Yes you can use it in NextJS
![Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Allegheny mound antOP
It works fine without
useEffect
, but not sure if it's good code like this.![Image](https://cdn.discordapp.com/attachments/1154328326526226462/1154331415501090816/Screenshot_2023-09-21_at_10.20.23.png)