NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 34

useMemo Hook - prevent to re-render

Avoid re-rendring in the functional component.

Here's is the Code !!

import React, { useState } from "react"
function App() {
  const [count, setData] = useState(1)
  const [item, setItem] = useState(20)

  const newApple=React.useMemo(
    function appleTime() {
      console.warn("Hello")
      return 100 * count;
    }
  ,[item])
  return (
    <div >
      <h1>Hooks in React {count}</h1>
      {newApple}
      <button onClick={() => setData(count + 1)}>Update State</button>
      <button onClick={() => setItem(item * 10)}>Update State</button>

    </div>
  );
}

export default App;

Chapter 33

Pure component in ReactJs

Previous chapter

Chapter 35

useRef Hook example - it helpfull for change DOM manupulation.

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

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