DEV Community

loading...

Discussion on: React's Odd Obsession With Declarative Syntax

Collapse
bytebodger profile image
Adam Nathaniel Davis Author • Edited

2) I'll probably be doing more of my future examples in Hooks, since I'm writing more of them for work and that's where my minds been turning to lately. But AFAIK, useEffect doesn't particularly solve these issues at all? As you've pointed out, it just provides a Hooks equivalent of componentDidUpdate and componentDidMount?

Collapse
isaachagoel profile image
Isaac Hagoel

I meant that even though useEffect (like every hook or anything else inside the render function) runs on every render it can be prevented from running its cleanup and effect code over and over again by passing in an explicit dependencies array (it still redundantly compares the dependencies on every render cycle to decide whether it needs to run but that's cheaper).