Redux Toolkit 2.0 is here! Find out what's changedand why, the work that's gone into repackaging the Redux libraries, an overview of new features and breaking changes, and a look at future plans.
What's New in Redux Toolkit 2.0
AI Generated Video Summary
Mark Erickson discusses the new features in Redux Toolkit 2.0, including the simplification of Redux logic and the addition of RTK query for data fetching. He mentions the challenges of achieving ESM common JS compatibility and refers to a blog post he wrote about it. The plan to ship major versions of RTK, Redux core, Reselect, and React Redux together is discussed, with a focus on the conversion of Redux core to TypeScript and the need for packaging updates and TypeScript type upgrades.
1. Introduction to Redux Toolkit 2.0
My name is Mark Erickson and I'm excited to talk about what's new in Redux Toolkit 2.0. Redux Toolkit simplifies Redux logic and includes RTK query for data fetching. We released RTK 1.0 in 2019 and are now working on RTK 2.0, which aims to improve compatibility and add new features. However, the ESM common JS compatibility has been challenging and I've written a blog post about it.
All right, good afternoon. My name is Mark Erickson, and today I am very excited to talk to you about what's new in Redux Toolkit 2.0.
I will answer questions anywhere there is a text box on the internet. I collect all kinds of interesting links. I write ridiculously long blog posts. I am a Redux maintainer, but most people know me as that guy with the Simpsons avatar. I know. Sometimes I wear a name tag just so people recognize me.
Redux Toolkit is the standard way to write Redux logic today. It provides methods to simplify standard Redux patterns, like creating stores, writing reducers, funcs, and even data fetching. It includes a sub-piece called RTK query, which is specifically meant to simplify data fetching in Redux apps, and it wraps around the Redux core APIs.
We released RTK 1.0 in October 2019, which if you think about it means it's been around half as long as the original Redux library, and yet, many people don't know about it. The latest version has been RTK 1.9. We shipped 1.9 a year ago. The latest patch release was 1.9.7.
Now, unfortunately, it turns out that this whole ESM common JS thing is really, really hard. I went through multiple rounds of iteration where I tried to change some settings, tried to change some build configuration, and multiple tools would not work right. It turns out that the package exports field is really complex, but the bigger issue is that every different build tool has their own idea of how they interpret these things. I was actually messing with this in the speaker's room an hour ago. It's not done yet. I actually ended up writing a very long blog post a few months ago, talking about the pain and suffering that I've dealt with trying to get this stuff to work.
2. Shipping Major Versions and TypeScript Upgrades
The plan was to ship major versions of RTK, Redux core, Reselect, and React Redux together. The Redux core was converted to TypeScript in 2019 but never shipped. All packages require packaging updates and some TypeScript type upgrades.
I talked about it on a couple podcasts as well. Now, the original plan was just to ship major versions of RTK and the Redux core. Then we realized that we actually probably needed to ship major versions of all the other libraries like Reselect and React Redux as well. The Redux core actually got converted to TypeScript in 2019, and then we never actually shipped it because version 4 was good enough and we were worried about breakage. We decided that all these packages need to get shipped, new major versions together. They all need the same packaging updates with a couple slight variations, and we were going to try and do some work to upgrade some of the TypeScript types and some of the exports that we were defining.