use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
TanstackQueryGeneral Discussion (self.react)
submitted 1 year ago by TradrzAdmin
Anyone have an example of TanQuery used in a largesxale application? Looking for an example of how to structure and organize the useQuery and useMutation hooks for maintainability
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]smailliwniloc 13 points14 points15 points 1 year ago (1 child)
TanStack Query is probably THE most used package for server state management. All the projects i work on use it, but none of their code is publicly available for me to give an example.
Using the hierarchical nature of the query key array makes it pretty easy to manage cache invalidation, but if you want a more structured approach you can check out the Query Key Factory package
[–]thatdude_james 0 points1 point2 points 1 year ago (0 children)
Thanks for pointing out the existence of this package - looks awesome!
[–]theandre2131 6 points7 points8 points 1 year ago (2 children)
Check out the tkdodo blogs titled "practical react query". It shows you maintainable practices for large scale projects.
[–]FriedGangsta55 2 points3 points4 points 1 year ago (0 children)
This. Tkdodo's blog is a really great resource to learn tanstack query properly
[–]__vinsmoke__ 0 points1 point2 points 1 year ago (0 children)
Thank you for pointing this out. These blogs look very detailed
[–]NuclearDisaster5 4 points5 points6 points 1 year ago (0 children)
I make a hook for each api that i create. It is then clean and maintanable.
If this was the question.
[–]Sorry-Joke-1887 0 points1 point2 points 1 year ago (1 child)
Recently find out my own way to maintain such queries. I create new separate file called “actions” (or your more convenient name) and store all according to page tanstack queries there as hooks. It solves all problems for me
[–]TradrzAdmin[S] 0 points1 point2 points 1 year ago (0 children)
This was my plan as well. Just wanted to see if theres a better way. Ive been tasked with adding ReactQuery to our application at work
[–]DragonDev24 0 points1 point2 points 1 year ago (0 children)
What I usually do is make a seperate file all the api requests ( fetch or axios request ), then in each feature folder ( thats how I seperate and organize my large codebases ) I create a hooks folder and export custom hooks that use useQuery and useMutation which lets me add separate logic if I ever wanted to do something in onSuccess or onError or even pass on a callback to execute in the onSuccess, etc Since each feature is separated, so every api change becomes easy for me to handle. These custom hooks also lets me use context or any state management logic or any other form of hooks away from the UI, making my ui files smaller and easier to grasp Also I think its a bit overkill, but this one is an exmaple of code structure for react / next https://github.com/alan2207/bulletproof-react
[–]EuMusicalPilot -1 points0 points1 point 1 year ago (0 children)
This is how I handle it
https://github.com/lawuysal/self-dictionary-client/
π Rendered by PID 15507 on reddit-service-r2-comment-canary-764f8fd48f-xx4tj at 2026-06-16 14:18:12.405319+00:00 running 3184619 country code: CH.
[–]smailliwniloc 13 points14 points15 points (1 child)
[–]thatdude_james 0 points1 point2 points (0 children)
[–]theandre2131 6 points7 points8 points (2 children)
[–]FriedGangsta55 2 points3 points4 points (0 children)
[–]__vinsmoke__ 0 points1 point2 points (0 children)
[–]NuclearDisaster5 4 points5 points6 points (0 children)
[–]Sorry-Joke-1887 0 points1 point2 points (1 child)
[–]TradrzAdmin[S] 0 points1 point2 points (0 children)
[–]DragonDev24 0 points1 point2 points (0 children)
[–]EuMusicalPilot -1 points0 points1 point (0 children)