Getting DOM node from React child element

后端 未结 6 1469
余生分开走
余生分开走 2020-12-04 17:14

Using the React.findDOMNode method that was introduced in v0.13.0 I am able to get the DOM node of each child component that was passed into a parent by mapping

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 18:07

    If you want to access any DOM element simply add ref attribute and you can directly access that element.

    
    

    And then you can directly:

    componentDidMount: function() 
    {
        this.refs.myinput.select();
    
    },
    

    Their is no need of using ReactDOM.findDOMNode(), if you have added a ref to any element.

提交回复
热议问题