useref hook

 import React,{useReffrom 'react'


export const FourthHook = () => {
  const inputref=useRef();
  const clickHandler=()=>{
      inputref.current.focus();
      inputref.current.value="";
      console.log(inputref.current.value);
  }
    return (
    <div>
        <input type="text" placeholder="example"
        ref={inputref} />
        <button onClick={clickHandler}>clickheretofocus</button>
    </div>
  )
}

Comments

Popular posts from this blog

interview questions js[ Anurag Singh ProCodrr]

reactnative_creation