DEV Community

Discussion on: A Practical Introduction to Using Redux with React

Collapse
 
markerikson profile image
Mark Erikson

Hi, I'm a Redux maintainer.

While this is a decent intro to how to write Redux code "by hand", I just published a brand-new "Redux Essentials" core docs tutorial, which teaches beginners "how to use Redux, the right way", using our latest recommended tools and practices. That includes Redux Toolkit as the default approach for writing the Redux logic, the React-Redux hooks API, and "ducks/slice" files. I'd encourage you to check it out:

redux.js.org/tutorials/essentials/...

I'd love to see this post updated to show use of Redux Toolkit.

Collapse
 
xavierbrinonecs profile image
Xavier Brinon

Which brings the next question, what content would be helpful? what do you whish to see the community is posting/publishing around the toolkit?

Collapse
 
markerikson profile image
Mark Erikson

Good question! And I'm not sure I have an exact answer atm.

Goodness knows there's a seemingly infinite number of "Intro to Redux" tutorials online already, all covering the same basic concepts.

My current desire is that everyone who's already using Redux would see RTK, and migrate over to it. I also want to see the community switching to teach RTK as the default, in the same way the React tutorials have all switched from "First, here's 30 pages of Babel+Webpack config..." to "Run npx create-react-app my-app".

In terms of teaching and writing stuff beyond that? I don't know exactly. It would be neat to see people start coming up with some interesting patterns on top of RTK's APIs like createSlice, createAsyncThunk, and createEntityAdapter, like some of the "CRUD slice" examples here:

github.com/reduxjs/redux-toolkit/i...

Beyond that, I've been working on an ongoing revamp of the Redux core docs. The Style Guide best practices page and the new "Redux Essentials" tutorial are two big pieces of that, and my next step is to rewrite the existing bottom-up tutorial sequence. But, there's a huge amount of work to do beyond that, and I'd love to have assistance from the community in working on the docs. See this overview of the docs rewrite effort for more details:

github.com/reduxjs/redux/issues/3592

Collapse
 
ddmytro profile image
Dmytro Danylov

Hi Mark. Thanks for your comment. I'll check your tutorial and update my post to show how to use Redux Toolkit.

Collapse
 
ddmytro profile image
Dmytro Danylov

I've added a chapter about using Redux Toolkit to the tutorial.

You did a really good job with Redux Toolkit. I really like how it simplifies the boilerplate. It makes the code shorter and more declarative. I liked the use of Immer behind the scenes to simplify writing state update logic.

So, in this tutorial, first, we cover the basic concepts, then we build a simple app using plain Redux and finally I explain how to transform/improve the Redux code we've written using Redux Toolkit.

Also, I've pointed out that using Redux Toolkit is a recommended approach to guide the readers in the correct direction for writing Redux apps.

Collapse
 
markerikson profile image
Mark Erikson

Thank you, and thank you! :)