<p>You can use React hooks to simulate componentDidMount and componentWillUnmount:</p>
<p><code>React.useEffect(() => {
// componentDidMount code here
return () => {
// componentWillUnmount code here
}
}, [])</code></p>
<p>Read more here: #example-using-hooks-1</p>