use effect v 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: useeffect only on mount
import React, { useEffect } from 'react';
function App() {
useEffect(() => {
// Run! Like go get some data from an API.
}, []);
}