Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hi, I'm a Redux maintainer. FWIW, we specifically designed our official Redux Toolkit package to not only eliminate the general concerns about Redux "boilerplate" [0] [1], but also work great with TS. With our recommended RTK+TS usage patterns, a typical "slice reducer" file only needs to define a type for the reducer's state, and then define a case reducer as `(state, action: PayloadAction<MyData>`) [2], and that's it.

We've put a _lot_ of work into making sure that our library TS types minimize the amount of types that you have to write in your own app code.

Also, one of the reasons we now teach the React-Redux hooks API as default is that it's drastically easier to use the hooks with TS than the legacy `connect` API.

If you haven't had a chance to see what "modern Redux" looks like, I'd suggest going through our docs tutorials to see how we want people to learn and use Redux today [3]

[0] https://redux.js.org/introduction/why-rtk-is-redux-today

[1] https://blog.isquaredsoftware.com/2022/06/presentations-mode...

[2] https://redux.js.org/tutorials/typescript-quick-start

[3] https://redux.js.org/tutorials/index



RTK is what made redux usable for me. I can't imagine using redux without it. ^ Mark is also very active and responsive in the Reactiflux discord and has directly helped me and countless others clear any hurdles with its use


Hooks made react and redux far less ridiculous. Class based react and redux wss maddening.

I’ll poke again but last time I tried I couldn’t avoid Typesafe Actions library.


Yeah, _please_ don't use `typesafe-actions` :)

It may have had some value before RTK came out, but a lot of the opinions and approaches shown in its docs lead you to write _wayyyy_ too much code. For example, we specifically recommend _against_ writing TS unions for action object types [0].

RTK completely obsoletes `typesafe-actions`, and the TS usage patterns that we teach today should result in a pretty minimal set of types that you need to write in your own code.

For a small example see the RTK+TS template for Create-React-App [1]. If you want to see what a real app codebase can look like, the client app for my day job at Replay.io is OSS [2]. It's admittedly a somewhat messy codebase due to its long evolution and legacy (started as the FF DevTools codebase, copy-pasted, and we've been slowly migrating to RTK+TS and modernizing it), but files like [3] show how I would write a real slice reducer with RTK+TS.

[0] https://redux.js.org/usage/usage-with-typescript#avoid-actio...

[1] https://github.com/reduxjs/cra-template-redux-typescript

[2] https://github.com/replayio/devtools

[3] https://github.com/replayio/devtools/blob/454804188d33900a26...




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: