ncaught Error: Invalid hook call

ncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
Rules of Hooks – React
The library for web and native user interfaces
6 Replies
Neto
Neto2y ago
you cant use hooks conditionaly
if(something === 1){
const ... = useState() // this is invalid
}
if(something === 1){
const ... = useState() // this is invalid
}
react query offers a enabled`parameter
Neto
Neto2y ago
Disabling/Pausing Queries | TanStack Query Docs
If you ever want to disable a query from automatically running, you can use the enabled = false option. When enabled is false:
gave_one
gave_oneOP2y ago
so I cannot put GetFilteredUsers any function I have to treated as a typical react state
benten
benten2y ago
useQuery is a hook
gave_one
gave_oneOP2y ago
@b_e_n_t_e_n (Rustular CEEO) sorry, but this isn't a different question how do u update t3 stack to have tailwind scss
Want results from more Discord servers?
Add your server