Dominik 🔮 Profile Banner
Dominik 🔮 Profile
Dominik 🔮

@TkDodo

37,188
Followers
382
Following
686
Media
18,159
Statuses

Software Engineer • Maintaining TanStack Query • blog at • Frontend Tech Lead @myadverity • ReactJs • TypeScript • Father of two 👧‍👦

🔮 building 🔜
Joined June 2009
Don't wanna be here? Send us removal request.
Pinned Tweet
@TkDodo
Dominik 🔮
6 months
📢 Earlier this year, I teamed up with the folks behind @uidotdev to build a brand new course for teaching the concepts of TanStack Query. I'm so happy to announce that we're getting close, and early registration is now possible at 🔮
54
59
553
@TkDodo
Dominik 🔮
6 months
📢Announcing TanStack Query v5 🎉🥳 🤝 unified object API 📈 simplified, optimistic updates ♻️ sharable mutation state 🔀 suspense and streaming w/ RSC ♾️improved infinite queries ⚡️ ~20 % smaller 🛠️new agnostic devtools 💾 fine-grained persistence
62
330
2K
@TkDodo
Dominik 🔮
3 months
components / hooks / types / utils (and constants) is the split I'm seeing in many codebases, yet it's the one I dislike the most. It groups by type, not by domain. "useTheme" will live next to "useTodo", but not next to ThemeProvider ... why?
Tweet media one
139
144
2K
@TkDodo
Dominik 🔮
10 months
📢 Yesterday, we released an experimental react-query-nextjs package for the app directory. Wrap your app in the <ReactQueryStreamedHydration> component to enjoy direct useQuery fetches on the server with suspense, which streams to the client 🎉 Example:
40
177
1K
@TkDodo
Dominik 🔮
2 months
PSA: Whenever you think of writing useEffect, the only sane thing is to NOT do it. Instead, go to the react docs and re-read the page about why you don't need an effect. You really don't. But what if I ne.. - NO. read the page! In my specia.. - NO. read the page! READ THE PAGE
65
126
951
@TkDodo
Dominik 🔮
5 months
default exports were a mistake
35
54
914
@TkDodo
Dominik 🔮
8 months
Everything
52
26
903
@TkDodo
Dominik 🔮
1 year
❤️ I've talked a lot about how I love zustand - I've been using it quite extensively over the last 3 years. 📚 This is the beginning of a series I've planned on "working with zustand". The intro is a bit basic, I want to go deeper in the future:
46
114
901
@TkDodo
Dominik 🔮
3 months
My wife just told me that a website to buy tickets doesn't work. Turns out she was just clicking the button before JS has finished hydrating so it did nothing 🙈. Thanks, SSR...
42
34
895
@TkDodo
Dominik 🔮
5 months
Use Server Components they said. It's gonna be great they said > Uncaught Error: Text content does not match server-rendered HTML. But which one ????
Tweet media one
110
28
851
@TkDodo
Dominik 🔮
2 years
Today's 🌶 take: Don't export functions just to write a unit test for them. If the function isn't used outside of the file in your app / library - don't test it. It's literally an implementation detail. Test the public interface only!
55
54
786
@TkDodo
Dominik 🔮
6 months
oh that explains sooo much about @Jira 😂. Like why I always need to reload pages to get new data, and that totally screws up the sorting because it's not persisted to the url. It's seriously bad UX, which is what you get a lot with hand-crafted solutions.
@rbolte
Remie Bolte
6 months
One of the blessings of working on @Atlassian apps is that I don't have to mess around with react-query or complex state management solutions. In most cases, it's a single fetch on page load, which can live happily inside useEffect() without too much drama
17
1
101
26
27
746
@TkDodo
Dominik 🔮
10 months
If you need another reason to not store tokens in localstroage, read this thread:
@PiotrSzlachciak
Piotr Szlachciak 💗
10 months
So basically it creates an iframe, reads iframe.contentWindow.localStorage.token and sends it as a query parameter to the external site.
3
18
190
18
130
728
@TkDodo
Dominik 🔮
11 months
📚 My take on React Query and Server Components is out. Sorry if it's not what you're expecting it to be 😅:
35
112
710
@TkDodo
Dominik 🔮
1 year
Every.freaking.time #reactquery
Tweet media one
19
49
694
@TkDodo
Dominik 🔮
2 years
🕵️We've fixed a huge performance problem this week by moving useState + context over to zustand. It was the same amount of code. The lib is < 1kb. ⚛️Don't use context for state management. Use it for dependency injection only. The right tool for the job!
26
64
670
@TkDodo
Dominik 🔮
2 years
📖 As promised, here is my article about callback refs and why they are better than useRef + useEffect if you want to do something with the element after it rendered:
29
119
659
@TkDodo
Dominik 🔮
7 months
So I wrote about why I think React.memo is worse than the other alternatives that exist to improve performance in a React app:
21
102
661
@TkDodo
Dominik 🔮
4 months
Please don't name your variables `renderTable` or `showIcon`. It is not helpful to read: { renderTable ? <Table data={data} /> : null } If we should render it, we render it. Thank you, Captain Obvious 🦸 Instead, try to name variables for what they represent:
Tweet media one
31
50
658
@TkDodo
Dominik 🔮
13 days
📚 It's been almost 1.5 years since I wrote my first blog post about working with zustand. It's about time I wrote a follow-up piece - about using zustand together with React Context
32
65
664
@TkDodo
Dominik 🔮
1 year
📢 TanStack Query v5.0.0-alpha.0 🔁 better infinite queries 💪 simplistic optimistic updates ⚡️ ~20% smaller bundlesize 🚫 removed overloads ☠️ dropped react17 support 🟦 needs TS 4.7 🎨 reduced API surface 🏝 solidJs: Island and streaming SSR support
19
64
646
@TkDodo
Dominik 🔮
11 months
And that, kids, is why we prefer-const.
@samselikoff
Sam Selikoff
11 months
TypeScript wizards: channel is defined on line 9 but possibly undefined on line 12. Any idea why?
Tweet media one
165
34
598
21
34
592
@TkDodo
Dominik 🔮
1 year
Why does it sometimes feel that open source moves a lot faster than the "real work" even though (or maybe because of?): - there are no estimations - no sprints - no retros - no pressure - no "process" - barely a roadmap Things ship and work, and quality is good, too...
47
73
586
@TkDodo
Dominik 🔮
5 months
🚩 component design red flag: A component should never need to know where it is rendered. This is the responsibility of the parent rendering it. <Link color={isInsideToolTip ? 'secondary' : 'primary'} />
16
33
571
@TkDodo
Dominik 🔮
1 year
👀👀
Tweet media one
29
48
558
@TkDodo
Dominik 🔮
7 months
Datepickers are the worst
44
21
564
@TkDodo
Dominik 🔮
2 months
😴 Tired: enabled not doing any type narrowing 🚀 Wired: the brand new skipToken 🔥 Now available in v5.25.0
Tweet media one
Tweet media two
24
43
542
@TkDodo
Dominik 🔮
2 years
useEffect is the `reduce` of hooks: - you can do anything with it - you probably shouldn't be using it - there are better abstractions
16
34
513
@TkDodo
Dominik 🔮
1 year
Optimistic updates will be a totally different, simplified experience in TanStack Query v5 🤯 We can now just render the variables of the running mutation instead of writing directly to the queryCache in `onMutate`
Tweet media one
20
38
510
@TkDodo
Dominik 🔮
1 year
@sebastienlorber The descriptiveness of a variable needs to be proportional to its scope. In a small scope like the shown .filter, anything, even `x` is good enough. No need to avoid the one letter abbrev here.
10
21
504
@TkDodo
Dominik 🔮
2 years
Are you storing access tokens in localstorage, and if so, why aren't you using cookies instead?
108
47
494
@TkDodo
Dominik 🔮
2 years
Not gonna lie that (as a maintainer of a library in the data fetching space) I'm feeling mostly afraid of server components and suspense. "How will this work with react-query" is a good question. It feels like I'm supposed to have an answer but I don't. Huge imposter syndrome rn
23
18
494
@TkDodo
Dominik 🔮
8 months
How to fix ?!
Tweet media one
78
15
490
@TkDodo
Dominik 🔮
1 year
📢 TanStack Query v5 alpha.34 has a new power feature for useQueries: A top-level `combine` option that lets us transform data from all Queries into whatever we want 🎉 Read more about it here: And try out the latest alpha version:
Tweet media one
27
59
486
@TkDodo
Dominik 🔮
1 year
It still amazes me how many people expect React Query to work in a way that is just _not_ how React works at all:
Tweet media one
23
27
482
@TkDodo
Dominik 🔮
10 months
Holy 🤯 react-query is used in ~ 1 out of every 6 react projects / installs. react weekly downloads: ~20m react-query (v3): ~1.5m @tanstack /react-query (v4+): ~1.8m Question is, what are the other 5 using 😁?
65
10
484
@TkDodo
Dominik 🔮
10 days
🔮 Exciting news: I'm so happy to announce that the course on TanStack Query I've been working on will launch May 22 🚀 Huge thanks to @tylermcginnis and the team behind @uidotdev for working with me on this 🙏
Tweet media one
13
40
481
@TkDodo
Dominik 🔮
2 years
One of my worst habits: I can't stop. I investigated a tricky problem today that I couldn't solve. At dinner, I was distracted, grumpy and agitated. I had to go back to the laptop until I found the cause. Now that I got it, my kids are already asleep. That wasn't worth it 😞
46
19
456
@TkDodo
Dominik 🔮
1 year
📚 Update time: All my react-query blogposts are now future proof, using the object syntax everywhere, which will be the only valid syntax starting with v5. After updating all the docs and examples, my blog was the last stop:
16
48
452
@TkDodo
Dominik 🔮
1 year
📚 Wrote a new blog post about being type-safe with react-query - as opposed to just using it together with typescript:
17
57
451
@TkDodo
Dominik 🔮
6 months
strong agree here 🙌 there's one tiny thing: you usually don't want to separate queryKey from queryFn. I know I've spread this pattern myself, and I'll write about why and how we've solved this in v5 soon.
@housecor
Cory House
6 months
How I use React query: 1. Create custom hooks that wrap related useQuery and useMutation calls. 2. Inline queryFn and mutationFn args. This enforces always using React query to query and mutate. 3. Colocate related queries and mutations in the same file, and invalidateQueries…
Tweet media one
54
109
1K
22
33
448
@TkDodo
Dominik 🔮
5 months
My wife told me she got an email from school twice and then we both go into full useEffect strict mode 😂😂
Tweet media one
14
7
437
@TkDodo
Dominik 🔮
6 months
I'm gaining hundreds of followers and the page views on my blog are through the roof 📈. Is it the orange site? Is it google trends? NO, it's a @t3dotgg video 😱
22
13
433
@TkDodo
Dominik 🔮
3 months
I think I mostly just want vite, TanStack Router + a standalone trpc server 🤔
34
6
434
@TkDodo
Dominik 🔮
2 years
Okay let's do this: Show me your weirdest usage of useEffect and I'll try to get rid of it ⚡️ No guarantees but I think a lot of effects I see in the wild are not necessary 😄
45
36
431
@TkDodo
Dominik 🔮
4 months
Things I'm proud of from 2023: 🔮reduced my job to two days a week to work on 🗣️ gave a talk in person at a @ReactVienna meet-up and @ReactSummit (remote) 🚢 shipped @tan_stack query v5 📚 my blog doing incredibly well (> 1M visits) 🎉 reached 30k…
12
7
428
@TkDodo
Dominik 🔮
1 year
tanstack/form 🤔
43
5
426
@TkDodo
Dominik 🔮
6 months
📚 New Blogpost: If you're wondering why you'd want a library like React Query, because you could just as well call fetch in useEffect, then this article is for you:
13
67
426
@TkDodo
Dominik 🔮
10 months
Why is everybody doing this: useQuery<Some, Types, Here>(...) instead of just typing the `QueryFunction` and inferring the rest. Is there an article or a video out there that tells everyone this is the way? Because it's not ...
44
28
425
@TkDodo
Dominik 🔮
4 months
🤪 Am I going crazy or is this a legit way to avoid hydration errors? Basically abusing `useSyncExternalStore` to safely read server snapshots on the server and on the first client render, and then falling back to the client snapshot. The good thing is that on client side…
Tweet media one
Tweet media two
19
39
420
@TkDodo
Dominik 🔮
1 year
📚 Have you ever wondered how react-query works internally? Why it is so efficient at managing async state? What a QueryObserver is? Then come with me as we take a look under the hood - inside react query...
17
72
419
@TkDodo
Dominik 🔮
1 year
📢 We will very likely be removing the onSuccess / onError / onSettled callbacks from `useQuery` in v5. I tried very hard to come up with a good use-case, but imo there is none. I'll write an RFC soon, but if you have a legit use-case, let me know now!
153
33
403
@TkDodo
Dominik 🔮
11 months
Maintaining an agnostic library is fun because you can do the weirdest things 😂 jquery-query:
Tweet media one
14
22
402
@TkDodo
Dominik 🔮
1 year
🌅Good morning from the part of our app that we haven't migrated to #TypeScript yet
Tweet media one
5
18
401
@TkDodo
Dominik 🔮
3 years
I'm super proud to announce that my blog has made it as a community resource into the official react-query docs 🎊 You can now read an excerpt of all my RQ related articles here: and the docs also link to them from other places. Thank you @tannerlinsley
26
34
399
@TkDodo
Dominik 🔮
8 months
📚 Getting back to valuable content: I wrote a blogpost today with all arguments I could find on why the generic notation (Array<string>) is better than the array notation (string[]) in TypeScript. Let me know if I missed anything:
43
52
397
@TkDodo
Dominik 🔮
3 months
📚 So I finally found the time to write about why we made the breaking parameter changes in v5, and what this new API enables us to do. Prepare to have your mind blown if you don't yet know what the Query Options API can do for you 🤯
12
44
397
@TkDodo
Dominik 🔮
1 year
📹Did you know that TanStack Query now has it's own eslint-plugin with rules that help you catch bugs early and stay future proof? I'm explaining what it can do for you in this video:
9
26
393
@TkDodo
Dominik 🔮
1 year
🔥The ReactQuery Devtools keep getting better and better: In the latest version, you can put your query into loading or error state to test how it behaves - all thanks to GitHub user paul-sachs 🎉
21
21
387
@TkDodo
Dominik 🔮
4 months
@jherr Hm, please don't store JWTs in client side storages 🙈. Store them in cookies created by the server (secure, http-only, same-site). I wanted to write an article about this a long time ago...
40
36
386
@TkDodo
Dominik 🔮
1 year
React Context is a lot closer to props than it is to state. To me, it's just prop drilling without having to write that code explicitly.
15
19
375
@TkDodo
Dominik 🔮
6 months
Updated all articles in my blog to be up to date with the latest v5 release of TanStack Query. Enjoy 🎉
16
22
378
@TkDodo
Dominik 🔮
11 months
📢 The slides + transcript of my talk "Thinking in React Query", which I gave both at a @ReactVienna meetup and @ReactSummit , are available on my blog now: I think this might just be the most important part in the whole series...
8
59
369
@TkDodo
Dominik 🔮
2 years
🤝React Query and React Router (the remixed one, v6.4) - how do they integrate? Should I use one or both for data fetching? I went through the tutorial and integrated RQ into it. Read about it here:
13
57
367
@TkDodo
Dominik 🔮
1 year
It's not the blogpost I wanted to write today, but it's the one I needed to write. I hope this will further shed some light on the issues. Why we are breaking the useQuery API on purpose
17
63
357
@TkDodo
Dominik 🔮
1 year
🌶️ hot take: optimistic updates are overrated and overused. They make sense for a small amount of interactions where instant feedback is necessary, but mostly, a pending state is just fine. I did write about this before:
19
25
353
@TkDodo
Dominik 🔮
9 months
If your contributions over 4 years aren't a net negative, are you even a senior engineer?
Tweet media one
14
9
348
@TkDodo
Dominik 🔮
1 year
Tweet media one
17
9
348
@TkDodo
Dominik 🔮
9 months
📢 TanStack Query v5 is now in beta 🎉 After 91 alpha releases over the last 5 months, we now believe our APIs are mostly stable - we don't have any plans to drastically change them.
9
36
347
@TkDodo
Dominik 🔮
8 months
just yolo'd `bun test` on our monorepo jest test suite. I didn't expect everything to pass, so the result is pretty good. The speed is absurd 🤯
Tweet media one
16
9
341
@TkDodo
Dominik 🔮
1 year
And that, kids, is why we don't force-push to main 😅🙈
Tweet media one
28
11
336
@TkDodo
Dominik 🔮
2 months
📹So I got nerd-sniped into making a Trellix clone with @tan_stack React Query over the weekend. I think it works really well, but feel free to disagree. No framework, no backend - just the great msw, vite + RQ SPA. Nice side-effect: it works if you lose network connection 😱
18
23
336
@TkDodo
Dominik 🔮
1 year
Should I start to stream some of the work I'll be doing on TanStack Query v5? Would that be interesting for you? Also, how does streaming work? 😅
29
2
326
@TkDodo
Dominik 🔮
7 months
📢Coming to you in v5: Fully interactive and editable data explorer in the Query devtools 🔥. All thanks to a contribution from @bastibuck 🚀 Now available in v5.0.0-rc.5
16
18
325
@TkDodo
Dominik 🔮
2 years
And finally, I met up with the one and only @tannerlinsley 🎉
Tweet media one
14
3
320
@TkDodo
Dominik 🔮
4 months
🤯 This honestly sounds so good. Not quite ready yet, but implementing a context selector with just the `use` and `useMemo` primitives is a really great design imo. A glimpse to the future 🔮
Tweet media one
@acdlite
Andrew Clark
4 months
@_cristianvr_ @TkDodo Current plan is to instead allow you to call use(context) inside of useMemo. Then the whole memo function acts as a “selector”.
2
4
78
17
36
322
@TkDodo
Dominik 🔮
7 months
📢 TanStack Query v5 is now available as a release candidate 🎉 This means we're pretty close to shipping it "as-is", unless you find and report things. There has never been a better time to try out v5 than RIGHT NOW
9
37
319
@TkDodo
Dominik 🔮
6 months
Okay, this is crazy. I was not ready to hit the 30k mark anytime soon. What an incredible, surreal day. Thank you everyone for sticking around with me ❤️. I'll have some new content to share tomorrow. Just you wait :)
16
3
322
@TkDodo
Dominik 🔮
1 year
TypeScript brought so much joy into writing JavaScript. May we forever enjoy this beloved language 🙏
17
19
319
@TkDodo
Dominik 🔮
2 years
🚀 react-query v3.30.0 is out with big news: query cancellation is now supported out of the box 📦: You'll get an `AbortSignal` passed to the queryFn, and can forward it to fetch / axios - RQ will do the rest 😮
7
38
316
@TkDodo
Dominik 🔮
2 years
The #TypeScript compiler might not be the fastest - but why is that such a big problem? "We have a large project" - I get that, but there are other things you can do that will impact development speed and DX:
21
32
313
@TkDodo
Dominik 🔮
9 months
Don't do monorepos unless you have someone (better a whole team) taking care of it.
@juristr
Juri · juri.dev
9 months
Quote tweet this with your spiciest 🌶️ monorepo take
0
3
18
27
28
311
@TkDodo
Dominik 🔮
19 days
I've put a bit too much on my plate lately. Working on @tan_stack Query v5, the 🔮 course, my day job as a tech-lead, consulting on the side, remeda v2, and now the router. It's unsustainable. So today, I've decided to take a step back from remeda. The lib is very mature and in…
12
2
314
@TkDodo
Dominik 🔮
1 year
The story of every code review, ever
Tweet media one
Tweet media two
17
21
296
@TkDodo
Dominik 🔮
2 months
@jamonholmgren react-query doesn't do data-fetching - it's an async state manager based on promises, so you don't need to copy data from react-query into another state manager. I have multiple blogposts and a talk on just this topic 😂
12
20
296
@TkDodo
Dominik 🔮
8 months
I was today years old when I found out that `setTimeout` uses a 32bit int for the delay value; everything larger will instantly trigger the passed function. We use this for garbage collection in React Query, so don't try to set a value larger than 596 hours (24.8 days) 😂
7
31
290
@TkDodo
Dominik 🔮
1 year
💁‍♂️React tip: I think most implementations of `usePrevious` will write to a ref in an effect and return it, but the rules of react advise us to not read refs during render. Here is my implementation, based on what I learned in the new react docs ():
Tweet media one
Tweet media two
13
23
288
@TkDodo
Dominik 🔮
1 year
Looks like I had 10 (ten) followers on Twitter when I joined the TanStack Discord in September 2020. This was my opening message in the "introductions" channel. It's surreal that I crossed 18k today. Can't believe how much open source has changed my life ❤️
Tweet media one
23
2
284
@TkDodo
Dominik 🔮
2 years
I have been asked a lot lately how to make your own low-level abstraction over useQuery and have it work in #TypeScript . My answer is usually: You don't need it, as those abstractions are often too wide. But there are use-cases for it, so here is my take. Let's break it down ⬇️
Tweet media one
10
32
287
@TkDodo
Dominik 🔮
6 months
@housecor "and" has no place in a variable name. it's a logical expression that screams "split me into multiple pieces" 😅
11
5
279
@TkDodo
Dominik 🔮
5 months
🏡Welcome home, @angular 🔥Amazing work by @Arnoud_dv on the new Signals based Angular adapter for TanStack Query ➡️Now available in v5.12: 🧪Marked as experimental but please try it out and give feedback 📚Docs are here:
5
42
278
@TkDodo
Dominik 🔮
5 months
How to add 500kb+ of JS to all pages? Easy: Have an un-optimized PNG (3k pixels wide), inline it into an SVG with base64 encoding, then render it as a React Component (svgr), which will inline it into the shared JS bundle 🤪 I'm not saying that's the code I just found 🙃
16
9
275
@TkDodo
Dominik 🔮
5 months
Not enough people, me included, understand how suspense works...
35
15
274
@TkDodo
Dominik 🔮
2 years
📢 announcing remeda v1.0.0 🚀 My favourite TypeScript utils library finally became "officially stable". If you're looking for a light-weight, type-safe, fully treeshakable, data-first and data-last replacement for lodash/ramda, give it a try:
10
34
271
@TkDodo
Dominik 🔮
1 year
I don't know what the edge is and at this point, I'm too afraid to ask 🙈
48
10
270
@TkDodo
Dominik 🔮
3 months
NOT
Tweet media one
19
3
263