It works and behaves the same, but wanted to know if there are any practical differences to setting a ref directly versus setting it via a callback that has the element as an argument.
Given this react hook component:
const myComponent = ({ ...props}) => {
const myRef = React.useRef(null);
...
return (
<div>
ref={myRef}
</div>
)
}
versus
const myComponent = ({ ...props}) => {
const myRef = React.useRef(null);
...
return (
<div>
ref={element => {
myRef.current = element;
}}
</div>
)
}