xored / scala-js-react

ScalaJS interface for Facebook React
Apache License 2.0
133 stars 13 forks source link

How to get the ref of a custom component in parent component? #19

Open freewind opened 9 years ago

freewind commented 9 years ago

Say I have two custom components, one has a button, other one has a link.

When I click on the button, I want to the link of another component be clicked.

If I can get the DOM of the link from the button component, I can easily do:

linkNode.click()

But in my case, I can't find a way to get the ref of the link in the button component. If I use pure reactjs, I can do:

refs('linkComponent').refs('link').getDOMNode().click()

But how to do the same with scala-js-react?

freewind commented 9 years ago

Found the example: https://github.com/xored/scala-js-react/blob/master/scalajs-react-examples/src/main/scala/com/xored/scalajs/react/examples/export/Export.scala