NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 28

Hook - useEffect with condition

In this explain how we can use multiple useEffect hook.

Its totaly conditional base execution.

Here's is the Code !!

import React, { useEffect, useState } from "react"
function App() {

  const [count, setCount] = useState(200)
  const [data, setData] = useState(1000)

  useEffect(() => {
    console.log("It run when count state is effected or change")
  }, [count])

  useEffect(() => {
    console.log("It run when data state is effected or change")
  }, [data])

  return (
    <>
      <h1>Here is the counter - {count}</<h1>>
      <button onClick={() => setCount(count + 1)}>Update Counter</button>
      <button onClick={() => setData(data + 1)}>Update Data</button>
    </>
  );
}

export default App;

Chapter 27

Use effect - (Hook)

Previous chapter

Chapter 29

Style in ReactJs and install bootstrap

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

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