how to create ref to class component code example
Example 1: use ref in component reactjs
function MyFunctionComponent() { return <input />;
}
class Parent extends React.Component {
constructor(props) {
super(props);
this.textInput = React.createRef(); }
render() {
// Ça ne fonctionnera pas !
return (
<MyFunctionComponent ref={this.textInput} /> );
}
}
Example 2: use ref in component reactjs
class CustomTextInput extends React.Component { // ...
}