The useEffect hook in React can be used to replicate the functionality of component lifecycle methods found in class-based components. By using different configurations of the useEffect hook, you can achieve the same effects as componentDidMount, componentDidUpdate, and componentWillUnmount. Here's how you can use useEffect to replicate the behaviour of these lifecycle methods:
No dependency array
Empty dependency array
Dependency array with values