怎么学习和了解一个技术点
import React from 'react';
import ReactDOM from 'react-dom';
class CustomTextInput extends React.Component {
constructor(props) {
super(props);
this.focus = this.focus.bind(this);
}
focus() {
// textInput是一个标准的DOM元素
this.textInput.focus();
}
render() {
return (
{
this.textInput = input;
}}/>
);
}
}
ReactDOM.render(
,
document.getElementById('root')
);
复制代码
class AutoFocusTextInput extends React.Component {
componentDidMount() {
this.textInput.focus();
}
render() {
return (
<CustomTextInput ref={input => {this.textInput = input; }} />
);
}
}
复制代码