Hacker News new | past | comments | ask | show | jobs | submit login

Cool but I would like to understand the opposite: why doesn't React then just memoize everything by default? Why not let the developer opt-out of memoizing instead of having them opt-in?



Memoization isn't a free lunch. I think React's approach is to keep it simple with not managing cache stores for absolutely everything. Most small to medium react apps need little to no use of useMemo to be performant.


If I remember correctly, React's default approach of comparing states/props is a shallow comparison (e.g. for PureComponent). That seems about as close to free as you can get.

I use PureComponent everywhere, but I don't know what people do in function-component world.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: