ampproject / amp-react-prototype

A scratch pad to experiment with React rendered AMP Components
Apache License 2.0
36 stars 9 forks source link

Trigger useResizeEffect on element changes #46

Open dvoytenko opened 4 years ago

dvoytenko commented 4 years ago

This approach uses a useCallback and passes the resulting function in place of a ref. It works correctly, but two main questions:

  1. Is "function as ref" a common enough pattern? Are there a lot of risks such as downstream propagation? Or if some other effect may want to have an element's ref?
  2. Are there any performance issues if the callback is not aligned with useEffect or useLayoutEffect timing?
CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.