Skip to content

Instantly share code, notes, and snippets.

@hg-pyun
Last active June 22, 2018 15:07
Show Gist options
  • Save hg-pyun/58bb1bdd61f936717781e5bf0154d7aa to your computer and use it in GitHub Desktop.
Save hg-pyun/58bb1bdd61f936717781e5bf0154d7aa to your computer and use it in GitHub Desktop.
react v16.3.0 medium 02
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.inputRef = React.createRef();
}
render() {
return <input type="text" ref={this.inputRef} />;
}
componentDidMount() {
this.inputRef.current.focus();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment