DEV Community

Discussion on: React Hooks and Lifecycle Methods

Collapse
 
brense profile image
Rense Bakker

Hmm yes, but honestly it's best to forget about lifecycle methods altogether, I've noticed some people switching from class components to hooks, trying to copy their lifecycle methods, but that won't work well. In class components there was no notion of dependencies, which is an important part of the hooks API. People moving their lifecycle methods from class components to hooks will try to work around this problem by either omitting dependencies from the useEffect hook, or trying all kinds of conditional logic inside the useEffect, to avoid triggering from its dependencies. In both cases the component will not work as expected.