Question 5 of 6Pro Only
How do React hooks relate to class component lifecycle methods?
Sample answer preview
React hooks provide a different mental model than class lifecycle methods, but you can achieve similar effects. componentDidMount runs once after the first render. The equivalent with hooks is useEffect with an empty dependency array: useEffect(() => { // runs once on mount },…
lifecycleuseEffectcomponentDidMountcomponentWillUnmountcleanup