DEV Community

Discussion on: Invalid hook call. Hooks can only be called inside of the body of a function component. ??

Collapse
 
jackmellis profile image
Jack • Edited

So you've got a useQuery (a react hook) inside a function that is only called inside a use effect callback. That's your problem. All react hooks must be called at the top level of the render function.

I don't know enough about your app to understand your setup but it feels weird that you're mixing apollo client with redux...

Collapse
 
gurupal profile image
Gurupal Singh

got it .. thanks

Collapse
 
gurupal profile image
Gurupal Singh

can i query graphql direct with axios and remove apollo client ?

Collapse
 
jackmellis profile image
Jack

Itd be very difficult to query graphql without some dedicated library but apollo client is an entire state management system so is overkill for what you need
There are several graphql libraries like npmjs.com/package/graphql-request