|
|
|
|
|
by brundolf
1403 days ago
|
|
For those pushing back, I wanted to share this talk given at a recent React Conf: https://www.youtube.com/watch?v=lGEMwh32soc The idea (still just an internal prototype) is that one day your compiler might automatically memoize all React components and intermediate values for you. It obviously would be great to skip all the syntax noise, as well as the linter-enforced rules around correctly maintaining dependency arrays, etc. But I think a big takeaway from this talk is that the React team sees memoizing as the norm. It is something to do by default, so much so that it may happen without your intervention one day. Immutability and value identity-based comparison are core to React. Violating these is the only way memoization can result in bugs (as some in this thread are worried about), and if you aren't following them then a lot of your React code is only working by accident to begin with, memo or no memo. |
|
How about we just do this:
import {useObey} from 'react'
// you may see no reason why you need to do this but just do it, not doing what you don't understand is obviously a fool's move.. btw.
const goodFn = useObey(myFn)
^// you'd better do this!
In OP's same article they are saying 'Senior' is just a title. Yeah juniors for sure will add an additional wrapper if you tell them. They'll add a useCallback around their useCallback for good measure. Part of being junior is just saying 'yes, mmhmm' to every thing that the hype train tells them to. I guess they are the real seniors since they listen so well.
You people pushing people to put all their callbacks in wrappers even if there is no discernible reason to, frankly suck and you're really sending the completely wrong message here. As a coder you should feel free to admit when you don't understand why something is told to you, and you should be comfortable not obeying the people who insist you need to just trust in their magic.