useeffect how to use component did mount code example
Example 1: use effect like component did mount
useEffect(() => {
console.log('I am the new componentDidMount')
}, [])
// Don't forget the empty array at the end
Example 2: react useEffect
import React, { useEffect } from 'react';
export const App: React.FC = () => {
useEffect(() => {
}, [/*Here can enter some value to call again the content inside useEffect*/])
return (
<div>Use Effect!</div>
);
}