News for hackers. Stuff that matters.
Re:A guide to useEffect in React by jameslk on Monday March 11, 2019 @03:05AM (#19357202)
> it's a lot of work

It should be a lot of work. There should be a penalty for this. State makes your code harder to reason about and should be avoided (i.e. contained) as much as possible.

> But I often need small bits of state all over the place

If you need small bits of state all over the place you may need to rethink things or use a state management system.

The spirit of React hooks might be to make things easier for certain edge cases but instead they will be abused by those who don't understand them to make their code harder to understand. Trust me, I've already started running into this with those who decided to cargo cult React hooks.

Re:A guide to useEffect in React by littlecranky67 on Monday March 11, 2019 @03:20AM (#19357249)
While it is true that you should not overuse state, it is almost impossible in real-world applications not to have it. I.e. a single UI toggle that shows/hides some content requires a field on the components state. Putting this in the props or even a state management container like redux would be overkill.
Re:A guide to useEffect in React by jameslk on Monday March 11, 2019 @03:27AM (#19357263)
I have built real world applications with React (consumer, insurance, B2B, I work at Facebook using React currently). I've handled some pretty crazy edge cases. I've never felt I needed something like hooks. The example you gave me sounds just fine for a "smart/dumb" component pattern[0]. If you need something between props and redux, there's plenty of existing options that work fine. React context and the render props pattern come to mind.

0. https://medium.com/@dan_abramov/smart-and-dumb-components-7c... (The author of this blog post pushes hooks now yet the pattern works well in most cases)