Relative Content

Tag Archive for reactjstypescripttanstackreact-query

Tanstack Query + useEffect

This code is working weirdly for useQuery. Apparently on the first button click useQuery will not get the updated value of count while the fetcher function gets the updated value (1). I observed that if you move the useEffect below the useQuery function it works fine. Putting the refetch in the dependency array requires putting the useEffect below the useQuery function.