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

Properties are proxies, but getters should be used for everything else. Why weren't getters also used for properties?



Props are getters. They are shallow. It are stores that are actual ES proxies.

I think the term is used loosely here to suggest that they are wrappers on top of objects. It isn't so much about the specifics but to explain why destructuring should be avoided.


Yes, by getters I was trying to refer to these wrappers.

  const valueGetter = () => props.value;


It's a fair question. Pre React Hooks I expected the proxy plain object approach to be more common. We definitely want consistency regardless if component consumer passes signal or literal, so I went that way. There are cases like with spreads where they are actual proxies too. But probably could have made all props are functions work and have them work with combination of proxies as well things just didn't play out that way.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: