DEV Community

Discussion on: React: useEffect explained with lifecycle methods

Collapse
 
guico33 profile image
guico33 • Edited

Small typo in the last code snippet. I believe you meant componentDidMount rather than componentWillMount in the first comment.

Also equivalent instead of eqivalent.

Collapse
 
adrianbdesigns profile image
Adrian Bece

Good catch. Thank you, I've fixed it now.

Collapse
 
guico33 profile image
guico33 • Edited

In addition to my previous comment, it is incorrect to say the dependency array doesn't affect the cleanup fn returned by the callback.

It is equivalent to componentDidUnmount if an empty array is passed, otherwise it will run whenever a dep changes, after the component has rendered with new props.

Thread Thread
 
adrianbdesigns profile image
Adrian Bece

Double checked with docs, you're right. I've fixed the post. Thank you again.