The equivalent of componentDidMount in hooks is the useEffect function. Functions passed to useEffect are executed on every component rendering—unless you pass a second argument to it.
What is useEffect for?
What does useEffect do? By using this Hook, you tell React that your component needs to do something after render. React will remember the function you passed (we'll refer to it as our “effect”), and call it later after performing the DOM updates.
Is componentDidMount a React hook?
useEffect is a React hook where you can apply side effects, for example, getting data from server. The first argument is a callback that will be fired after browser layout and paint.