I am trying to use refs in React. They always return the root DOM node of the component instead of the deferred one.
Please consider the following example:
var AuthApp = React.createClass({ onSubmitClick: function(event) { var usernameInput = this.getDOMNode(this.refs.username); // This logs root <div> instead of <input>, why??? console.log(usernameInput); }, render: function() { return ( <div> <input type="text" ref="username"/> <input type="password" ref="password"/> <input type="submit" onClick={this.onSubmitClick} /> </div> ); } });
I checked the code in the excellent Chrome React addon and it seems that this.refs.username correctly reflects the <input> :

Something goes wrong when I call this.getDOMNode - it returns the root <div> specified in render() instead of <input> .
This code comes from React 0.12, but I tried to do the same at 0.13 (I know of a change to React.findDOMNode() ), and I get the same result.
What am I doing wrong?
source share