This works perfectly fine in React version 0.12:
componentDidMount: function () {
var dom = this.getDOMNode();
}
The variable dom
gets the actual DOM node for the rendered component. However, converting this to React 0.13 does not work as expected:
componentDidMount: function () {
var dom = React.findDOMNode();
// dom is undefined
}
I tried React.findDOMNode(this)
which does not work either. Basically I'm just trying to fetch the top-level dom node rendered by the render function without using a ref. Is this possible?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…