Skip to content

Instantly share code, notes, and snippets.

@codeaholicguy
Created March 8, 2016 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeaholicguy/1742a385f2bea3fa469b to your computer and use it in GitHub Desktop.
Save codeaholicguy/1742a385f2bea3fa469b to your computer and use it in GitHub Desktop.
var Form = React.createClass({
focusOnField: function(){
React.findDOMNode(this.refs.textField).focus();
},
render: function(){
return (
<div>
<input
type="text"
ref="textField" />
<input
type="submit"
value="Focus on the input!"
onClick={this.focusOnField} />
</div>
);
}
});
var App = React.createClass({
render: function(){
return (
<div>
<h1> Welcome to the focus app!</h1>
<Form />
</div>
);
}
});
React.render(<App />, document.getElementById("app"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment