Function refs are great and all, except they arent really as composable, this is partly because they recieve a single "null" value when unmounting.
If someone also wanted to do something to the referene when unmounting one would need to:
- Store the refs when mounting.
- Retrieve it when unmounting.
But this inheretly ties us to some statefull abstraction like class components, because storing it in a variable or object with function components traps us into only being able to use the ref function for at most one instance of a component.
However, if we managed to have both the target and currentTarget as a reference we wouldn't need to store the ref.
As a final touch to improve the ergonomics on this front. When a ref function returns a function, the return value(the function) should be used when unmounting. Alternatively this may be exactly/only what we need.