News for hackers. Stuff that matters.
Re:A guide to useEffect in React by rajangdavis on Monday March 11, 2019 @02:31AM (#19357090)
When do you actually need to use hooks? I saw a nice visual where hooks ended up reducing code, but I am not sure I grok it.
Re:A guide to useEffect in React by jameslk on Monday March 11, 2019 @02:35AM (#19357105)
I've been using React in projects large and small for years and I can remember VERY FEW situations where I said to myself "gee I wish I could bundle a bunch of state or side effects together and share it between components like React mixins of lore". If you can't think of a situation where you need it, that's probably because you don't. Anything plain old JavaScript class components can't handle here were solved by using HOCs/render prop patterns or React context (often in the form of state management libraries such as Redux).
Re:A guide to useEffect in React by sorahn on Tuesday March 12, 2019 @10:23AM (#19368376)
> HOCs/render prop

Both of these inflate the VDOM, and present themselves as a false hierarchy that your app requires. HOCs artificially inflate the props that any component requires, and it's harder to see what props you're actually supposed to pass to the component, vs the ones that should come from a HOC. Hooks remove a lot of these anti-patterns.

Re:A guide to useEffect in React by snek on Monday March 11, 2019 @02:33AM (#19357095)
When you want to work with state in a component (so most of the time) but are too stubborn to admit FP isn't the right choice for the job
Re:A guide to useEffect in React by jameslk on Monday March 11, 2019 @02:41AM (#19357123)
This is my feeling too to be honest. I think hooks are very misguided. Unfortunately it's no longer FP anymore when your "referential transparency" has been completely blown away.
Re:A guide to useEffect in React by jordanwallwork on Monday March 11, 2019 @05:43AM (#19357726)
FP?
Re:A guide to useEffect in React by jameslk on Monday March 11, 2019 @02:45PM (#19361637)
Functional Programming