ReactでDOMの要素を直接取得・変更する方法
構文
//取得 var test = React.findDOMNode(this.refs.${ref名}).${取得したい要素名}; //格納・変更 React.findDOMNode(this.refs.${ref名}).${変更したい要素名} = '';
Example
render: function() { return ( <div> <input type="text" ref="command" /> </div> ); }
上記のinputタグの中身を、例えば空に戻したい時(データ送信後に次の入力のためにクリアするとか)は、以下のようにすればOKです。
React.findDOMNode(this.refs.command).value = '';