Answers for "react useref in useeffect"

0

react useref in useeffect

import React, { useEffect, useRef } from 'react';

const fooComponent = props => {
	const inputBtnRef = useRef(null);
  	useEffect(() => {
      //Add the ref action here
      inputBtnRef.current.focus();
    });
  
  	return (
      <div>
        <input
          type="text"
          ref={inputBtnRef} 
		/>
      </div>
    );
}
Posted by: Guest on January-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language