Home

Published

- 1 min read

useEffect syhntax react

img of useEffect syhntax react

The solution for this is noted below

useEffect syhntax react

Solution

   // remember to import this
import React, { useState, useEffect } from 'react';

function Example() {
  const [count, setCount] = useState(0);
//use effect
  useEffect(() => {
    document.title = `You clicked ${count} times`;
  }, [//dependencies array]);

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}

Try other methods by searching on the site. That is if this doesn’t work