Skip to content

Instantly share code, notes, and snippets.

@Sigmus
Last active August 29, 2015 14:21
Show Gist options
  • Save Sigmus/f8afc38251cd4b9a90a7 to your computer and use it in GitHub Desktop.
Save Sigmus/f8afc38251cd4b9a90a7 to your computer and use it in GitHub Desktop.
React mixin to focus element with ref="firstInput"
const React = require('react');
module.exports = {
componentDidMount() {
this.focusFirstInput();
},
focusFirstInput() {
const input = this.refs.firstInput; // <input ref="firstInput" />
if (input) {
React.findDOMNode(input).focus();
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment