React: How to access returned HTML within a React Component


/ Published in: JavaScript
Save to your folder(s)

Within a react component. How to gain access to the HTML that was just rendered.

Any returned html element that is tagged with a ref, can easily be accessed by it's ref after it's been rendered. In the below case, use this.refs["domainModal"] to access the html. This access is limited to within the scope of the instance of this react component.


Copy this code and paste it in your HTML
  1. accessDiv: function(){
  2. var test = this.refs["domainModal"]
  3. }
  4.  
  5.  
  6. render: function(){
  7. return <div ref="domainModal"></div>
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.