News for hackers. Stuff that matters.
Re:Two custom React hooks by xixixao on Friday December 17, 2021 @10:07AM (#29593136)
Redux is far from the suggestion, and imho unless you can greatly benefit from the actions boilerplate its overhead is not worth it.

As others mentioned useImmer is a more bulletproof solution then assuming your state can always be modeled by a single layer Object though.

Re:Two custom React hooks by 5e92cb50239222b on Friday December 17, 2021 @10:29AM (#29593467)
Redux Toolkit doesn't require much boilerplate anymore (IMHO). I found Redux to be absolutely appalling and never used it (despite having some familiarity with functional programming and the ideas underlying Redux) before RTK came along.
Re:Two custom React hooks by acemarke on Friday December 17, 2021 @10:48AM (#29593757)
Heh, glad to hear that RTK is an improvement there :)
Re:Two custom React hooks by bayesian_horse on Friday December 17, 2021 @10:26AM (#29593426)
I too felt like that for a long time. Eventually I got when and why Redux is useful, even with the boilerplate. Also, modern semantics and utilities greatly help. Redux Toolkit, RTK Query, reselect and so on.

Actions make state more debuggable. Selectors make rendering more performant and often help structure complex rendering logic. Also, Redux is a way of not having to define asynchronous control flow by composing components, which can get really messy.

Granted, it's not necessary for every app.

Re:Two custom React hooks by handrous on Friday December 17, 2021 @10:40AM (#29593639)
I like Redux because it's portable—you can easily rip it out of a React project and use it anywhere—and because it provides a really nice way to separate backend-talking-stuff from frontend-rendering-stuff, if you're dividing up dev tasks. Nice clean place to split off a library for whatever service(s) you're consuming.

And with Typescript, it's not a bit unpleasant to work with.