explorer icon indicating copy to clipboard operation
explorer copied to clipboard

Replace all uses of `useEffect` with `useQuery`

Open mvadari opened this issue 10 months ago • 2 comments

https://react.dev/learn/you-might-not-need-an-effect

mvadari avatar Feb 19 '25 02:02 mvadari

@mvadari can i try?

Agastya18 avatar Feb 19 '25 06:02 Agastya18

@Agastya18 sure, go ahead

mvadari avatar Feb 19 '25 19:02 mvadari

Hi @Agastya18 , if you're not working on it, I'd like to work on it. Thanks!

Deeptanshu-sankhwar avatar Mar 03 '25 11:03 Deeptanshu-sankhwar

Ya sure, u can

Agastya18 avatar Mar 03 '25 11:03 Agastya18

What’s up! I came across this issue and wanted to throw my hat in... swapping out useEffect for useQuery? Right up my alley,,, I love clean, optimized React.

Quick heads-up,,, I’ve got a solid two-week window right now and I’m planning to contribute to at least 7 solid projects during that time. Yours is definitely one I’d love to be part of.

I’ve been in the blockchain game since 2017... as a Forbes Tech Council writer, investor, and builder. Been deep in the dev side for a while now... especially around blockchain + React/Web3 stacks.

Here’s a link to some of my work if you wanna peep: https://vyudu-links.netlify.app/

Let me know if you’re cool with me taking this on... happy to make it smooth and clean.

Cheers,

VyuduInc avatar Jun 16 '25 16:06 VyuduInc

@mvadari The linked tutorial page does not make a mention of useQuery react hook. Are you referring to this third-party library's useQuery hook?

useEffect is used to synchronize external systems based on changes in the internal component (state/ref/context) values. useQuery appears to be a way to asynchronously query the external world for information (possibly, without any changes to the react components internal state). I don't quite see how the two are always inter-changable.

ckeshava avatar Jul 31 '25 23:07 ckeshava

@mvadari The linked tutorial page does not make a mention of useQuery react hook. Are you referring to this third-party library's useQuery hook?

This is the package we currently use for the useQuery hook (see the package.json), which does appear to have been rebranded for v4 onwards to the link you sent.

useEffect is used to synchronize external systems based on changes in the internal component (state/ref/context) values. useQuery appears to be a way to asynchronously query the external world for information (possibly, without any changes to the react components internal state). I don't quite see how the two are always inter-changable.

They're not, but a good chunk of the old useQuery usages in this repo are querying the external world for information. And probably many of the other uses of useEffect can be replaced to something better, as the tutorial linked above describes.

mvadari avatar Aug 04 '25 14:08 mvadari