NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 35

useRef Hook example - it helpfull for change DOM manupulation.

Hook alway start with use keyword.

Here's is the Code !!

import React,{useRef} from "react"
function App() {
  let inputRef=useRef(null);
  function controlInput()
  {
  //  inputRef.current.value="abc"
  // inputRef.current.style.display="none"
  inputRef.current.focus()
  }
  return (
    <div className="App">
      <h1>useRef in React </h1>
      <input type="text" ref={inputRef} />
      <button onClick={controlInput}>Handle Input</button>
    </div>
  );

}

export default App;

Chapter 34

useMemo Hook - prevent to re-render

Previous chapter

Chapter 36

What is forwardRef

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex