get ref react functional component code example
Example 1: cre&atRefs react js
const node = this.myRef.current;
Example 2: createref in functional component
function CustomTextInput(props) {
// textInput must be declared here so the ref can refer to it
const textInput = useRef(null);
function handleClick() {
textInput.current.focus();
}
return (
<div>
<input
type="text"
ref={textInput} />
</div>
);
}