mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 04:33:10 +00:00
19 lines
348 B
JavaScript
19 lines
348 B
JavaScript
class MyComponent extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
// highlight-next-line
|
|
this.inputRef = React.createRef();
|
|
}
|
|
|
|
render() {
|
|
// highlight-next-line
|
|
return <input type="text" ref={this.inputRef} />;
|
|
}
|
|
|
|
componentDidMount() {
|
|
// highlight-next-line
|
|
this.inputRef.current.focus();
|
|
}
|
|
}
|