React synchronizes the DOM according to our current props and state. There is no distinction between a “mount” or an “update” when rendering.
This is subtly different from the familiar mount/update/unmount mental model.
useEffect lets you synchronize things outside of the React tree according to our props and state
If you’re trying to write an effect that behaves differently depending on whether the component renders for the first time or not, you’re swimming against the tide!
useEffect()
props
andstate
. There is no distinction between a “mount” or an “update” when rendering.useEffect
lets you synchronize things outside of the React tree according to our props and stateReference: https://overreacted.io/a-complete-guide-to-useeffect/