javascript - Is the ref property the only way to access the DOM in a ReactJS application? -


is ref property of components idiomatic way "escape world of reactjs" , interact dom directly when working in reactjs application?

clearly document.queryselector in componentdidmount, other that...

class app extends react.component{      componentwillmount(){          console.log(reactdom.finddomnode(this))      }        componentdidmount(){          console.log(reactdom.finddomnode(this))      }      render(){          return(               <div>wefewfewfewfwefewf</div>          )      }  }    reactdom.render(    <app />,document.getelementbyid("app")  )
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>  <div id="app"></div>

you can use reactdom.finddomnode. takes react component , returns underlying dom element.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -