class Person extends Component {
constructor(props) {
super(props);
this.inputElementRef = React.createRef();
}
componentDidMount() {
//this.inputElement.focus();
this.inputElementRef.current.focus();
}
render() {
console.log("[Person.js] rendering...");
return (
<Aux>
<p onClick={this.props.click}>
I'm a <b>{this.props.name}</b> and am {this.props.age} years old !
</p>
<p>{this.props.children}</p>
<input
type="text"
//ref={inputEl => {
// this.inputElementRef = inputEl;
//}}
ref={this.inputElementRef}
onChange={this.props.changed}
value={this.props.name}
/>
</Aux>
);
}
}