1//This is a way to build this effect as a custom hook
2import React, { useEffect, useRef } from 'react';
3
4const useDidMountEffect = (func, deps) => {
5 const didMount = useRef(false);
6
7 useEffect(() => {
8 if (didMount.current) func();
9 else didMount.current = true;
10 }, deps);
11}
12
13export default useDidMountEffect;