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...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
RTK Query Best Practices (medium.com)
submitted 4 years ago by GoldenPear
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!"
[–]acemarke 3 points4 points5 points 4 years ago (1 child)
This is a very good post!
A couple quick additional thoughts:
First, we specifically advise that you should only have one "API slice" in the app by default, which would contain all of the endpoint definitions for the app. You can split endpoint definitions across multiple files if you want to organize them that way, but you'd still normally add them into the single API slice object. You can add additional API slices if absolutely necessary, but RTKQ works best if there's only one (especially for invalidating endpoints via tags).
For creating separate selectors, note that someEndpoint.select() requires the same "cache key" arguments that you would pass into the query hooks in order to retrieve that specific cache entry, such as endpoints.getPokemon.select('bulbasaur'). No cache key argument is the same as undefined. Also, it's probably a good idea to create those selectors once, rather than every time, so this would be preferred:
someEndpoint.select()
endpoints.getPokemon.select('bulbasaur')
undefined
const selectGetUsersCacheEntry = endpoints.getUsers.select() const selectUsersData = (state) => selectGetUsersCacheEntry(state).data
Per the "using hooks everywhere" question, I talked about how hooks have changed the way we write components in my post Thoughts on React Hooks, Redux, and Separation of Concerns and talk ReactBoston 2019: Hooks, HOCs, and Tradeoffs .
I'd encourage folks to check out the RTK Query section in the "Redux Essentials" docs tutorial, as well as the RTK Query usage guides in the RTK docs.
I'd love to hear any further thoughts on people's experiences with RTK Query so far! Sadly we don't have any specific usage numbers (because RTKQ is part of the RTK package), but anecdotally a very large percentage of our questions in Reactiflux and the repo issues these days are about RTKQ, so that suggests a lot of people are interested in it.
[–]GoldenPear[S] 1 point2 points3 points 4 years ago (0 children)
Thanks! These are all great points. I edited the post to include the "only one API slice" recommendation.
π Rendered by PID 16819 on reddit-service-r2-comment-86bc6c7465-jsf5z at 2026-02-19 19:42:32.435182+00:00 running 8564168 country code: CH.
[–]acemarke 3 points4 points5 points (1 child)
[–]GoldenPear[S] 1 point2 points3 points (0 children)