I'm trying to use react components like that:
<Dialog ref='dialog'>
....
<Row ref='item'/>
....
</Dialog>
Why can't I use this.refs.item
in my code?
P.S. I solved this by another way, but this question is interested me yet.
I'm trying to use react components like that:
<Dialog ref='dialog'>
....
<Row ref='item'/>
....
</Dialog>
Why can't I use this.refs.item
in my code?
P.S. I solved this by another way, but this question is interested me yet.
You can access the mounted DOM element with this.refs.item
in this way.
Also for your child (row) component.
See working JSBIN with demo here.
How to achieve this depends on the version of react you are using.
In react version 0.13.1 you still need to use React.findDOMNode(this.refs.item)
to get the DOM element. In later versions (0.14) this.refs.items
points to:
<MyComponent ref="foo"/>
See also react documentation here, with important warnings and advise about when to use or not to use refs.