did mount in react hooks code example
Example 1: component did mount in hooks
For componentDidMount
useEffect(() => {
// Your code here
}, []);
For componentDidUpdate
useEffect(() => {
// Your code here
}, [yourDependency]);
For componentWillUnmount
useEffect(() => {
// componentWillUnmount
return () => {
// Your code here
}
}, [yourDependency]);
Example 2: react hook will mount
const useComponentWillMount = (func: (params?: any) => any) => useMemo(func, []);