News for hackers. Stuff that matters.
Re:A Critique of React Hooks Addendum by davedx on Thursday May 07, 2020 @01:12PM (#23105412)
I can give my take on this.

Until hooks I used redux in every app because it was the default way to manage state. Now I use hooks, I have more tools to help me manage state (and also load things via useEffect), I find I simply don't need redux anymore. The only compelling reason for me to pull in redux now would be if I wanted a centralised cache, but the kind of line of business apps I mostly work on lately just don't need to cache things like that, so each route/page just reloads the data from the server.

Re:A Critique of React Hooks Addendum by dceddia on Thursday May 07, 2020 @11:13PM (#23111033)
If you want a lightweight cache, check out react-query[0]. It's a nice abstraction around fetching data, and it handles caching out of the box, as well as refetching data when the browser regains focus and a lot of other nice things.

0: https://github.com/tannerlinsley/react-query

Re:A Critique of React Hooks Addendum by davedx on Friday May 08, 2020 @05:50AM (#23113025)
Thanks, I'll check it out.

I find using apollo's graphql client library solves this reasonably well too, though the syntax is a bit clunky and knowing when you need to explicitly define a cache function or not is tricky.