Dominik ๐Ÿ‡ณ๐Ÿ‡ด React Norway

โš›๏ธ Maintaining TanStack Query ๐Ÿ”ฎ https://query.gg ๐Ÿ‘จโ€๐Ÿ’ป Software Engineer @sentry.io ๐Ÿ“š Blog at https://tkdodo.eu ๐Ÿ‡ฆ๐Ÿ‡น Vienna, Austria ๐Ÿ‘ง๐Ÿ‘ฆ Father of two

9250 followers487 following90 stories

Longform Stories

TanStack Router and Query

TanStack Router has a built-in cache, so why would we need TanStack Query? There are, of course, reasons ...

May 26ยท1 min readยท23 words

The Vertical Codebase

Let's take a look at why the common, horizontal code structure is not ideal, where it breaks down, and what we can do about it.

Apr 13ยท1 min readยท28 words

Test IDs are an a11y smell

Users don't use data-testid, so why do your tests?

Mar 23ยท1 min readยท15 words

Creating Query Abstractions

Building reusable abstractions on top of libraries that rely on type inference can be deceptively difficult, which is why we need better ways to build those abstractions ...

Feb 23ยท1 min readยท31 words

Building Type-Safe Compound Components

Compound Components are great, but should be type-safe. No, this isn't about the children prop ...

Jan 2ยท1 min readยท20 words

2025 in Review

A retrospective on what has happened for me in 2025

Dec 26ยท1 min readยท13 words

Designing Design Systems

I want to write more about what makes a good design system. This is the unstructured list of principles I think matter.

Dec 1ยท1 min readยท25 words

Omit for Discriminated Unions in TypeScript

Why TypeScriptโ€™s built-in Omit breaks discriminated unions, and how a distributive version preserves them.

Nov 24ยท1 min readยท20 words

Tooltip Components Should Not Exist

A look at why tooltip components are often the wrong abstraction in design systems, leading to accessibility issues, misuse, and inconsistent user experiences.

Nov 17ยท1 min readยท28 words

Context Inheritance in TanStack Router

An overview of how TanStack Router automatically shares and infers path params, search params, and context between nested routes in a type-safe way.

Oct 12ยท1 min readยท28 words

Deriving Client State from Server State

How to use derived state in React to keep client state and server data aligned without manual sync or effects.

Sep 1ยท1 min readยท26 words

React Query Selectors, Supercharged

How to get the most out of select, sprinkled with some TypeScript tips.

Aug 4ยท1 min readยท17 words

The Useless useCallback

Why most memoization is downright useless...

Jul 28ยท1 min readยท9 words

The Beauty of TanStack Router

Yes, it's type-safe, but there's so much more to love about TanStack Router.

May 25ยท1 min readยท18 words

Concurrent Optimistic Updates in React Query

How to build optimistic UI that is resilient to race conditions, even when multiple mutations update the same entity concurrently.

Apr 28ยท1 min readยท26 words

My Open Source Origin Story

A brief story of how I got into Open Source

Mar 31ยท1 min readยท15 words

2024 in Review

A retrospective on what has happened for me in 2024

Dec 29ยท1 min readยท13 words

React Query - The Bad Parts

In this talk, maintainer Dominik will explore the other sideโ€”the less favorable aspects of React Query and situations where it may not be the best fit. No library is perfect; every choice involves traโ€ฆ

Dec 28ยท1 min readยท64 words

Ref Callbacks, React 19 and the Compiler

Reflecting on useCallback, how the Compiler changed my thinking about it, and what React 19 has in store for Ref Callbacks...

Dec 8ยท1 min readยท28 words

My Slow Retreat from Twitter

A brief reflection on the platform and how I plan to continue with it...

Dec 3ยท1 min readยท19 words

React Query API Design - Lessons Learned

In this talk, React Query maintainer Dominik will walk us through some of the API design choices that were made in React Query to get to that DX. You'll hear stories about things that went well, but aโ€ฆ

Oct 25ยท1 min readยท61 words

Component Composition is great btw

Component composition is one of the best parts of React, and I think we should take more time to break our components into manageable parts before littering one component with conditional renderings.

Sep 21ยท1 min readยท37 words

How Infinite Queries work

A serious bug report about infinite queries led me to question it's architecture, but it all turned out fine in the end ...

Sep 14ยท1 min readยท27 words

Introducing XState Store

There's a new state manager in the game, and it ticks all my boxes ...

Aug 1ยท1 min readยท18 words

Please Stop Using Barrel Files

Why you probably shouldn't be adding index.ts files everywhere

Jul 26ยท1 min readยท14 words

React 19 and Suspense - A Drama in 3 Acts

React 19 is a very promising release - but there's something not quite right yet with suspense...

Jun 16ยท1 min readยท27 words

Automatic Query Invalidation after Mutations

Even though there is nothing built into React Query, it doesn't need a lot of code to implement automatic query invalidation in user-land thanks to the global cache callbacks.

May 25ยท1 min readยท34 words

Zustand and React Context

Zustand stores a global and don't need React Context - but sometimes, it makes sense to combine them regardless.

Apr 14ยท1 min readยท23 words

Avoiding Hydration Mismatches with useSyncExternalStore

Avoiding hydration mismatches can usually be done in two ways - suppressing the warning or spawning an effect. But is there a third option ... ?

Feb 21ยท1 min readยท31 words

The Query Options API

v5 brought a new, powerful API, especially if you're using React Query with TypeScript...

Jan 17ยท1 min readยท18 words

2023 in Review

A retrospective on what has happened for me in 2023

Dec 30ยท1 min readยท13 words

Why You Want React Query

Let's take a look at why you'd want a library like React Query, even if you don't need all the extra features it provides...

Nov 7ยท1 min readยท29 words

The Uphill Battle of Memoization

Exploring why React.memo shouldn't be your first choice for performance optimizations

Sep 30ยท1 min readยท16 words

Array Types in TypeScript

is string[] really better than Array<string>? Of course not!

Aug 19ยท1 min readยท13 words

React Query and React Context

Can it make sense to combine React Query with React Context ? Yes, sometimes ...

Jul 22ยท1 min readยท20 words

Thinking in React Query

In this talk, we will learn how a different mindset can help us understand React Query and work with it efficiently.

Jun 7ยท1 min readยท25 words

You Might Not Need React Query

React Query is a great library, but like any tool, you should choose it for the right problem

May 20ยท1 min readยท24 words

Breaking React Query's API on purpose

Why good API design matters, even if it means breaking existing APIs in the face of resistance.

Apr 16ยท1 min readยท23 words

OSS Feature Decision Tree

An outline of the questions I try to ask myself before adding new features

Feb 18ยท1 min readยท18 words

Why React isn't dying

Finishing my train of thought about why React is here to stay (for now).

Jan 29ยท1 min readยท18 words

Type-safe React Query

About the difference between "having types" and "being type-safe"...

Jan 7ยท1 min readยท12 words

2022 in Review

A retrospective on what has happened for me in 2022

Dec 31ยท1 min readยท13 words

Inside React Query

Taking a look under the hood of React Query

Dec 3ยท1 min readยท12 words

Working with Zustand

Let's dive into some tips for working with Zustand - one of my favourite client state management libraries in React.

Nov 20ยท1 min readยท23 words

Refactor impactfully

Why not every refactoring is worth doing...

Nov 13ยท1 min readยท9 words

Seeding the Query Cache

With suspense for data fetching on the horizon, it is now more important than ever to make sure your cache is seeded properly to avoid fetch waterfalls.

Oct 22ยท1 min readยท31 words

Refs, Events and Escape Hatches

Refs can provide a way to sidestep dependency arrays without violating any rules, and the proposed useEvent hook might make working with functions and effects a lot easier...

Sep 17ยท1 min readยท33 words

React Query meets React Router

React Query and React Router are a match made in heaven.

Aug 28ยท1 min readยท16 words

Avoiding useEffect with callback refs

Interacting with DOM nodes doesn't necessarily need useEffect

Aug 14ยท1 min readยท13 words

React Query FAQs

Answering the most frequently asked React Query questions

Jun 24ยท1 min readยท11 words

Hooks, Dependencies and Stale Closures

Let's demystify what stale closures are in combination with react hooks with the help of the analogy of taking a photo ...

Apr 24ยท1 min readยท27 words

React Query and Forms

Forms tend to blur the line between server and client state, so let's see how that plays together with React Query.

Apr 10ยท1 min readยท25 words

Use Urgency

Getting huge refactorings going is not an easy task, but urgency can help here.

Mar 25ยท1 min readยท16 words

optional vs. undefined

There is a subtle difference between optional fields and required, but potentially undefined ones.

Feb 19ยท1 min readยท17 words

Offline React Query

A glimpse at what v4 will bring for offline queries

Feb 5ยท1 min readยท13 words

Always provide customer value

Finding the right spot for doing a refactoring can be tricky

Jan 29ยท1 min readยท15 words

Road to Refactoring

A blogpost series about patterns that have helped me succeed with refactorings

Jan 22ยท1 min readยท15 words

2021 in Review

A retrospective on what has happened for me in 2021

Dec 21ยท1 min readยท13 words

Beware the leaking any

Any is not among my favourite TypeScript types, but it is the one you will inevitably encounter. Let's see what makes it so dangerous.

Dec 4ยท1 min readยท28 words

Leveraging the Query Function Context

Use what React Query provides for optimal type safety

Oct 26ยท1 min readยท14 words

Mastering Mutations in React Query

Learn all about the concept of performing side effects on the server with React Query.

Oct 9ยท1 min readยท20 words

useState vs useReducer

To useState or useReducer, that is the question...

Sep 26ยท1 min readยท11 words

React Query Error Handling

After covering the sunshine cases of data fetching, it's time to look at situations where things don't go as planned and "Something went wrong..."

Sep 10ยท1 min readยท28 words

React Query as a State Manager

Everything you need to know to make React Query your single source of truth state manager for your async state

Aug 20ยท1 min readยท26 words

Placeholder and Initial Data in React Query

Learn about the different possibilities to avoid loading spinners in React Query.

Aug 9ยท1 min readยท19 words

About async functions

A deep dive into async functions and how they are different from promise chaining

Jul 23ยท1 min readยท17 words

Effective React Query Keys

Learn how to structure React Query Keys effectively as your App grows

Jun 13ยท1 min readยท16 words

Using WebSockets with React Query

A step-by-step guide on how to make real-time notifications work with react-query

Jun 6ยท1 min readยท17 words

React Query and TypeScript

Combine two of the most powerful tools for React Apps to produce great user experience, developer experience and type safety.

May 16ยท1 min readยท24 words

How can I ... ?

Asking the right questions is a form of art that needs to be mastered.

Apr 24ยท1 min readยท19 words

Testing React Query

Let's take a look at how to efficiently test custom useQuery hooks and components using them.

Apr 4ยท1 min readยท19 words

Status Checks in React Query

How the wrong status check order can negatively impact user experience

Mar 27ยท1 min readยท16 words

React Query Render Optimizations

An advanced guide to minimize component re-renderings when using React Query

Mar 20ยท1 min readยท15 words

useState for one-time initializations

Why you shouldn't rely on useMemo for guaranteed referential stability but prefer useState instead

Mar 12ยท1 min readยท18 words

React Query Data Transformations

Learn the possibilities to perform the quite common and important task of transforming your data with react-query

Mar 10ยท1 min readยท21 words

No love for boolean parameters

Innocent looking boolean parameters, or flags, are often the reason for hard to maintain legacy code. Resist the urge of adding them!

Feb 28ยท1 min readยท27 words

Things to know about useState

5 things everyone needs to know about useState

Feb 13ยท1 min readยท13 words

Simplifying useEffect

useEffect hooks can be hard to reason about, but I have 5 principles that can help to manage them

Jan 23ยท1 min readยท21 words

Flow to TypeScript migration journey

How we migrated over 100k lines of code from Flow to TypeScript. A Journey.

Jan 4ยท1 min readยท19 words

On naming things

Naming is hard. Naming is subjective. Yet there are some things we can objectively do when it comes to finding proper names.

Dec 8ยท1 min readยท25 words

Practical React Query

Let me share with you the experiences I have made lately with React Query. Fetching data in React has never been this delightful...

Nov 16ยท1 min readยท26 words

Avoiding legacy systems

Every software will eventually become a nightmare to maintain, unless we actively do something about it.

Nov 1ยท1 min readยท19 words

Putting props to useState

Part deux of the useState pitfalls series is here, showing patterns to help solve the common use-case of initializing state with a prop.

Oct 25ยท1 min readยท27 words

The power of const assertions

const assertions are a criminally underused TypeScript feature - learn all about them here, now

Oct 8ยท1 min readยท20 words

Pedantic index signatures in TypeScript 4.1

Accessing objects and arrays has never been safe in TypeScript, but this is about to change ...

Sep 20ยท1 min readยท23 words

Why I don't like reduce

If you know me, you know I'm no fan of Array.reduce. I'll explain why in detail in this post.

Sep 9ยท1 min readยท24 words

Calling JavaScript from TypeScript

Gradually migrating from JS to TS is not without difficulties - here are some tricks to smoothen the interoperability

Sep 4ยท1 min readยท23 words

Solving conflicts in package-lock.json

Why you should never delete package-lock.json and how npm can solve the conflicts for you

Sep 2ยท1 min readยท19 words

Don't over useState

The first part of the useState pitfalls series is all about avoiding state altogether. Lots of things might not even be state after all...

Aug 29ยท1 min readยท27 words

Exhaustive matching in TypeScript

Aug 9ยท1 min readยท4 words