hi, I just don't know how to get a original HTMLElement in ReactElement? Just like getDOMNode() in ReactComponent?
Elements are light-weight objects with no knowledge of HTML elements. I'm not sure exactly what you're asking or why you would need it but if you're looking to get "div" from
you can access .type.var el = <div />;
console.log(el.type); // "div"
like this <ScrollView><Text>hello</Text></ScrollView>
, "ScrollView.children" return [ReactElement],
but i can't get the real HTMLElementNode by ReactElement. Because I want getComputedStyle of the <Text>
node;
A ReactElement doesn't correspond to a DOM node until you mount it in the DOM using React.render
.
var element = <ScrollView><Text>hello</Text></ScrollView>;
var component = React.render(element, container);
var node = React.findDOMNode(component);
Most helpful comment
A ReactElement doesn't correspond to a DOM node until you mount it in the DOM using
React.render
.