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

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...




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

Search: