React Query - The Bad Parts

This ad is not shown to multipass and full ticket holders
React Summit
React Summit 2026
June 11 - 15, 2026
Amsterdam & Online
The biggest React conference worldwide
Learn More
In partnership with Focus Reactive
Upcoming event
React Summit 2026
React Summit 2026
June 11 - 15, 2026. Amsterdam & Online
Learn more
Bookmark
Rate this content

React Query is a popular library for managing asynchronous state—most often state returned from data fetching. Its popularity has grown significantly over the past few years, with nearly 20% of all React applications now using it.
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 trade-offs. By the end of this talk, you'll have a better understanding of React Query's limitations and why it remains a compelling choice despite them.

This talk has been presented at React Day Berlin 2024, check out the latest edition of this React Conference.

FAQ

React.js is a JavaScript library for building user interfaces, particularly single-page applications where data changes over time.

Using React.js with TypeScript helps catch errors at compile time and enhances the development environment with type checking and better IntelliSense support.

To start using React.js, you need a basic understanding of HTML, CSS, and JavaScript. Familiarity with ES6 features and Node.js is also beneficial.

React.js improves application performance by using a virtual DOM to efficiently update and render components.

React.js is a library, not a full-fledged framework, mainly focusing on building UI components.

Yes, React.js can be used for mobile app development through React Native, which allows you to build mobile apps using React.

The main advantage of React.js is its ability to efficiently update and render just the right components in response to data changes.

You can request data in a React.js application using JavaScript's Fetch API or libraries like Axios to make HTTP requests.

React.js can be optimized for SEO with techniques like server-side rendering (SSR) using frameworks like Next.js.

JSX is a syntax extension for JavaScript that looks similar to XML or HTML, and it's used in React.js to describe what the UI should look like.

Dominik Dorfmeister
Dominik Dorfmeister
30 min
13 Dec, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
React Query is a popular library with significant weekly downloads and positive user sentiment. It may have trade-offs like bundle size, but the actual size shipped is smaller. Bundle size optimization can be achieved by exporting only necessary features. React Query's declarative approach eliminates the need for custom data fetching solutions. It offers caching, request duplication, background updates, and more. RackQuery doesn't support normalized caching, but refetching after invalidation works fine. React's vision includes suspense architecture and server components. The documentation could be improved with a more structured flow. TensorStack Query can be a good choice for Next.js apps, but not necessary with mature frameworks. The 10 stack query and router concepts were discussed. Combining React Query with HTTP caching provides a robust caching solution.
Available in Español: React Query - Las partes malas

1. Introduction to React Query

Short description:

React Query is loved by the community for its developer experience and user experience. It has significant weekly download numbers and is used in about 20% of React applications. Surveys show that the majority of users have a positive sentiment towards React Query.

React Jets Introduction to React Query A short introduction to React Query React Query, the bad part. I really hope this is going to be a quick one, like a lightning talk, really, because I think mostly React Query is just great. I think it's loved by the community for the developer experience and the user experience it provides. I know that's a bold claim, so I tried to bring some evidence to back that up.

If we look at the weekly download numbers on NPM, I think React Query has grown a lot this year from almost 4 million to 6 million weekly downloads. I think those are huge numbers, and if we compared it to the React numbers, which is also, React is growing strong, sitting at about 27 million weekly downloads, all of a sudden the curve doesn't look as impressive anymore, but I think we can still take away from that, that React Query is used in about 20% of our React applications or in almost every fifth app. Some of those apps, they have millions of users themselves, like Sentry, Blue Sky, or JetGPT, so I think React Query really gets a lot of exposure.

Now, of course, download numbers and usage and exposure aren't everything, just because something is used doesn't actually mean that it's liked. So maybe a better way would be to look at surveys. There is the State of Frontend 2024 survey, which asked the question, which tools have you used to fetch data in the last year? Now, I'm not going to nitpick here that React Query is not a data-fetching library, like Axios or Fetch, that are listed here, but behind those, it actually comes in with a very positive sentiment, because only 2.8% of people who used it didn't like it. And State of React has a similar question around utilities for loading and managing data, and if we group that by positive sentiment, then TensorStripe Query actually comes out at the top with a little bit over 44%. So I'm really happy that developers seem to like the library, because I've been maintaining it for the last four years.

2. React Query: Trade-offs and Bundle Size

Short description:

React Query has trade-offs and is not always the perfect fit. One commonly mentioned drawback is the bundle size, but the actual size that gets shipped to consumers is much smaller than what is seen on npm.

My name is Dominic. I'm a software engineer living in Vienna, where I will be joining the frontend platform team at Sentry in the next month. And you can find me as TK Dodo online almost everywhere, and I also have a blog where I write about React and TypeScript, and of course, React Query.

Now, I've written and talked a lot about why React Query is great, and I still think it really is, but, you know, everything is a trade-off. And if we use any technology, it's usually a good trade-off if the thing we are getting in return is worth more to us or is better for us than what we are trading in. Now, I think React Query is really a good trade-off for most situations, but, of course, there are cases where it might not be the best fit or the perfect fit. So today, I want to talk about these cases, but also maybe debunk some myths that I've heard about it that make it sound like it's bad when it actually maybe isn't. So maybe the talk should be more like React Query, the trade-offs.

Okay. Let's get started with the first point, the elephant in the room, which is the bundle size. That React Query has a huge bundle size is something that I often hear as its largest drawback. And to get to the bottom of that, we first have to establish what the bundle size isn't, because it's not what you see on npm, right? This is the size that gets shipped to the developers when they install the library. Yes, it's over 700 kilobytes, but it also includes all the sources and source maps for you to better debug the library.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

A Guide to React Rendering Behavior
React Advanced 2022React Advanced 2022
25 min
A Guide to React Rendering Behavior
Top Content
This transcription provides a brief guide to React rendering behavior. It explains the process of rendering, comparing new and old elements, and the importance of pure rendering without side effects. It also covers topics such as batching and double rendering, optimizing rendering and using context and Redux in React. Overall, it offers valuable insights for developers looking to understand and optimize React rendering.
Building Better Websites with Remix
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a web framework built on React Router that focuses on web fundamentals, accessibility, performance, and flexibility. It delivers real HTML and SEO benefits, and allows for automatic updating of meta tags and styles. It provides features like login functionality, session management, and error handling. Remix is a server-rendered framework that can enhance sites with JavaScript but doesn't require it for basic functionality. It aims to create quality HTML-driven documents and is flexible for use with different web technologies and stacks.
React Compiler - Understanding Idiomatic React (React Forget)
React Advanced 2023React Advanced 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
Watch video: React Compiler - Understanding Idiomatic React (React Forget)
Joe Savona
Mofei Zhang
2 authors
The Talk discusses React Forget, a compiler built at Meta that aims to optimize client-side React development. It explores the use of memoization to improve performance and the vision of Forget to automatically determine dependencies at build time. Forget is named with an F-word pun and has the potential to optimize server builds and enable dead code elimination. The team plans to make Forget open-source and is focused on ensuring its quality before release.
React Query API Design – Lessons Learned
React Advanced 2024React Advanced 2024
26 min
React Query API Design – Lessons Learned
Top Content
I'm super excited to be here today, giving my first live talk at an in-person conference. Dominik, the maintainer of React Query, walks through the API design decisions, including success stories, trade-offs, and mistakes. Tener Linsley designed React Query's medium-sized query API to be minimal, intuitive, powerful, and flexible. Major versions in open source require marketing efforts, but not primarily for adding new features. TypeScript is crucial for building projects and managing user demands in open source can be challenging. The addition of the max pages option improved performance and avoided unnecessary refetches. Inversion of control gives users flexibility, but mistakes can happen in API design. Open source requires time management and feedback from users. API design is influenced by typing ease and good TypeScript support. Getting involved in open source involves trial and error and joining community platforms like TanStack Discord. Dominik's journey started during the pandemic and he can be found on Twitter, TanStack Discord, and his blog.
Using useEffect Effectively
React Advanced 2022React Advanced 2022
30 min
Using useEffect Effectively
Top Content
Today's Talk explores the use of the useEffect hook in React development, covering topics such as fetching data, handling race conditions and cleanup, and optimizing performance. It also discusses the correct use of useEffect in React 18, the distinction between Activity Effects and Action Effects, and the potential misuse of useEffect. The Talk highlights the benefits of using useQuery or SWR for data fetching, the problems with using useEffect for initializing global singletons, and the use of state machines for handling effects. The speaker also recommends exploring the beta React docs and using tools like the stately.ai editor for visualizing state machines.
Routing in React 18 and Beyond
React Summit 2022React Summit 2022
20 min
Routing in React 18 and Beyond
Top Content
Routing in React 18 brings a native app-like user experience and allows applications to transition between different environments. React Router and Next.js have different approaches to routing, with React Router using component-based routing and Next.js using file system-based routing. React server components provide the primitives to address the disadvantages of multipage applications while maintaining the same user experience. Improving navigation and routing in React involves including loading UI, pre-rendering parts of the screen, and using server components for more performant experiences. Next.js and Remix are moving towards a converging solution by combining component-based routing with file system routing.