Style components don't forward refs to the underlying components
Closed this issue · 2 comments
ahmedlhanafy commented
const TitleLabel = styleSpan('TitleLabel', theme => ({
fontWeight: theme.titleLabelFontWeight as FontWeightProperty
}));
const MyComp = () => {
const ref = React.useRef();
React.useEffect(() => {
console.log(ref); // this will log the component instance not the underlying DOM node and AFAIK there isn't a way to access the DOM node, there are originalRef and itemRef but both yield `undefined`
})
return <TitleLabel ref={ref}></TitleLabel>
}
You can refer to this: https://reactjs.org/docs/forwarding-refs.html
hatpick commented
try originalRef
property
ahmedlhanafy commented
originalRef
works