Closed bluenote10 closed 5 years ago
I needed a way to pass a ref out from a DOM element to its Component. Like this:
const Component = props => <div forwardRef={props.ref} />
const App = props => {
let someRef;
return <Component ref={someRef} />
}
This compiles to:
const Component = props => function () {
const _el$ = _tmpl$.content.firstChild.cloneNode(true);
props.ref && props.ref(_el$);
return _el$;
}();
const App = props => {
let someRef;
return Component({ ref: r$ => someRef = r$ });
};
So as it turns out I added a function based ref on DOM nodes unintentionally. Not sure if I should make a thing out of it. In any case the type looks like it was wrong. Thanks for the PR. I will merge immediately. Although it might take me a little bit to get it published to npm. I am right in the middle of some refactoring.
I still don't understand what a
forwardRef
is semantically. According to the type definitions it is the same as aref
, but in #14 you mentioned it is a callback. Does this just need an adjustment of the type definition here?