TkDodo
tkdodo.eu · Personal blog · on HN since 2021
Dominik Dorfmeister (TkDodo), a React Query maintainer, writes about React, TanStack libraries, TypeScript, and frontend code structure.
What HN saysHN commenters recommend it for understanding React Query, including query keys and type narrowing, and it comes up in debates over React's callback model.
21HN people shared it
3linked it in comments
20stories submitted
164story points
4 months agolast shared
2021people per year2026
Most-shared posts
- 1The Vertical Codebase3 people · 6 points · first shared 2026 · discussion on HN
- 2The Useless UseCallback2 people · 110 points · first shared 2025 · 112 comments on HN
- 3Please Stop Using Barrel Files2 people · 16 points · first shared 2024 · 4 comments on HN
- 4Tooltip Components Should Not Exist2 people · 9 points · first shared 2025 · discussion on HN
- 5Type-Safe React Query2 people · 3 points · first shared 2023 · discussion on HN
- 6Hooks, Dependencies and Stale Closures1 people · 6 points · first shared 2022 · discussion on HN
- 7The Beauty of TanStack Router1 people · 3 points · first shared 2025 · discussion on HN
- 8Working with Zustand1 people · 3 points · first shared 2022 · discussion on HN
- 9XState Store – TkDodo's Blog1 people · 2 points · first shared 2025 · discussion on HN
- 10React Query meets React Router (v6.4)1 people · 2 points · first shared 2022 · discussion on HN
- 11Array Types in TypeScript1 people · 1 points · first shared 2023 · discussion on HN
- 12Using WebSockets with React Query1 people · 1 points · first shared 2022 · discussion on HN
- 13Building Type-Safe Compound Components1 people · 1 points · first shared 2026 · discussion on HN
- 14Avoiding Hydration Mismatches with UseSyncExternalStore1 people · 1 points · first shared 2024 · discussion on HN
- 15React query and type script1 people · first shared 2021
What HN people wrote when they linked it
fabian2k · 2023-10-19
It was more of a general misunderstanding on how React Query is supposed to work, partially triggered by some mistakes in defining the query keys that meant that React Query didn't work as intended.
I'd recommend this blog post (or actually all blog posts on React query on that site):
https://tkdodo.eu/blog/effective-react-query-keys
What I observed was that the query keys were not consistently defined, which broke automatic refetching when the data was modified and invalidated. So the developer added some manual refetches because they thought React Query couldn't handle that automatically.
You need a consistent structure for your query keys and use that everywhere. Then you only need to make sure to invalidate the correct part of the query key hierarchy and the rest works automatically.
tshaddox · 2021-11-03
I believe this will also obviate a common recommendation to not destructure when using React Query: https://tkdodo.eu/blog/react-query-and-type-script#type-narrowing
CharlieDigital · 2025-09-15
Actually, React's problem is that it's the inverse of how HTML and JavaScript works in terms of how to handle callbacks. Of the major UI frameworks, it is the only one with this quality (Vue, Svelte, Angular, Solid, etc. use signals).
This inverted behavior is the cause of most of the pain and footguns in React and React Hooks because the way state behaves in a React component is not the way state behaves in any other front-end JS one would normally write.
That's why I think for some folks who started with HTML + vanilla JS, React Hooks just feels wrong. It points the reactive callback to the component function whereas every other framework/library uses some sort of signal to point the reactive callback to a handler. Because React points the callback to the component function, then you have to be really cautious about where you put state inside of a component[0][1][2]
Even You wrote this about React's design choice which I think sums it up best:
> The pain and suffer[ing] of hooks all roots from the mismatch between a dogmatic belief in the superiority of immutability and the harsh reality of the host language that is JavaScript If you want to "feel" this for yourself, here are a series of JSFiddles:
- Vanilla: https://jsfiddle.net/qtmkbdo2/8/
- Vue: https://jsfiddle.net/vys2rmup
- React: https://jsfiddle.net/0gjckrae/1/
It should be obvious that Vanilla and Vue behave like how one would expect callbacks to work. React, because it points the callback to the…