A guide to useEffect in React

A guide to useEffect in React

Functions can “see” values from props and state — so they participate in the data flow. It’s worth emphasizing this — our function gets called many times (once per each render), but every one of those times the value inside of it is constant and set to a particular value (state for that render). So even if we speak of a single conceptual effect here (updating the document title), it is represented by a different function on every render — and each effect function “sees” props and state from the particular render it “belongs” to.

Source: overreacted.io