Files
react.dev/examples/16-3-release-blog-post/create-ref-example.js
2018-03-18 08:03:28 -07:00

15 lines
293 B
JavaScript

class MyComponent extends React.Component {
// highlight-next-line
inputRef = React.createRef();
render() {
// highlight-next-line
return <input type="text" ref={this.inputRef} />;
}
componentDidMount() {
// highlight-next-line
this.inputRef.current.focus();
}
}