2022-04-08
2931
#react#redux
Zain Sajjad
19451
Apr 8, 2022 ⋅ 10 min read

Smarter Redux with Redux Toolkit

Zain Sajjad Head of Product Experience at Peekaboo Guru. In love with mobile machine learning, React, React Native, and UI designing.

Recent posts:

React logo on a bubbly orange background. Guide on building adaptive and responsive UIs in React Native for diverse devices.

Creating adaptive and responsive UIs in React Native

Design React Native UIs that look great on any device by using adaptive layouts, responsive scaling, and platform-specific tools.

Chinwike Maduabuchi
Nov 15, 2024 ⋅ 9 min read
Enhancing Two-Way Data Binding In Angular

Enhancing two-way data binding in Angular

Angular’s two-way data binding has evolved with signals, offering improved performance, simpler syntax, and better type inference.

Alexander Godwin
Nov 14, 2024 ⋅ 6 min read
Hand holding purple sticky notes for CSS sticky positioning guide.

Troubleshooting CSS sticky positioning

Fix sticky positioning issues in CSS, from missing offsets to overflow conflicts in flex, grid, and container height constraints.

Ibadehin Mojeed
Nov 13, 2024 ⋅ 5 min read
Task Scheduling and cron Jobs in Node Using node-cron

Scheduling tasks in Node.js using node-cron

From basic syntax and advanced techniques to practical applications and error handling, here’s how to use node-cron.

Godwin Ekuma
Nov 12, 2024 ⋅ 7 min read
View all posts

3 Replies to "Smarter Redux with Redux Toolkit"

  1. Thanks for writing this article!

    A few quick thoughts:

    – I specifically [chose thunks for use in RTK instead of sagas for a variety of reasons](https://blog.isquaredsoftware.com/2020/02/blogged-answers-why-redux-toolkit-uses-thunks-for-async-logic/). In general, sagas are a great power tool, but most Redux apps don’t actually need them (and especially not just for basic data fetching).
    – Similarly, I’ve never been particularly fond of the whole “container/presentational” concept. It’s not _bad_, but the community has way-over-obsessed on it. That’s why Dan Abramov has said [he no longer supports that idea](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0), and when I rewrite the Redux core tutorial, I’ll be removing that phrasing entirely.
    – “Ducks” are not a competitor to “containers”, because “containers” were always about component structure. Ducks are an alternative to having separate folders for actions/reducers/constants, or even having separate files for those in a single feature folder.
    – I’d suggest expanding the post to show some examples of `createSlice` in action, and especially how Immer makes immutable updates of objects a lot simpler.

  2. Hi Mark, Thanks a lot for taking out time and giving such valuable feedback.

    1) Redux Thunk: I have already mentioned that Thunk is default middleware for async tasks. I specifically mentioned saga since thunk has been discussed in docs and many other tutorials. Also by this I was able to explain option to add middleware.
    Remedy: I am making it more prominent that why I opted for Saga & Thunk is the recommended approach.

    2/3) I mentioned this update on Dan’s article in my previous posts, but as a concept (Segregating store and presentational layer of app), I feel this is still very helpful in many large scale apps. Since I considered example of react-boilerplate I went with CP pattern. CP already had concept of grouping reducer/action/constants based on feature, I feel ducks took that idea a step ahead. I am still open to updates in post if you feel this might lead to any misconceptions in community.
    Remedy: I am rephrasing it upgrade section

    4) Though I am not a big fan of long posts, unless they are coming from you 😉 I will add code of createSlice as a example. About Immer and immutability, post already shed some light on this adding more here will make it a little heavy IMHO.

    Once again thanks for sharing these findings.

  3. Ohh yes, compare how much simpler you can do all of the above with Hookstate: https://hookstate.js.org/ (Disclaimer: I am a maintainer). It will be fast by default without any sorts of selectors. It will be smaller size as the core package is powerful without any extra libs. But it is also extendable with plugins, and standard plugins assist with persistence, state validation, etc… What do you think?

Leave a Reply