Last active
August 29, 2015 14:21
-
-
Save Sigmus/f8afc38251cd4b9a90a7 to your computer and use it in GitHub Desktop.
React mixin to focus element with ref="firstInput"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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