DEV Community

shrish
shrish

Posted on

React question about api fetch

I am a jr react developer and slowly learning things. i have a doubt whenever i create a custom hook for api call or use react query hook for usequery to get api data, i want some time this call happen when some event trigger or some specific parameters change. so how to do that if i use it as hooks i have to call it in the top layer of the component, then what should i do write a function for the api call then it will be repeation of the same code. in this scenario what principal should i follow? any help will be appreiciated

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay