Posted By

heathbo on 01/23/16


javascript React

Versions (?)

React: How to access returned HTML within a React Component

 / Published in: JavaScript

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.

  1. accessDiv: function(){
  2. var test = this.refs["domainModal"]
  3. }
  6. render: function(){
  7. return <div ref="domainModal"></div>
  8. }

Report this snippet  

You need to login to post a comment.