React HooksLesson 48Free preview
React useEffect
This lesson is part of React · All levels
Summary
UseEffect runs side effects after a component is rendered to a DOM, such as retrieving data, subscribing to an event, or changing a page title. The dependency list determines whether the effect is run again, and the effect containing the cleaner should restore the cleanup function. Proper dependency prevents over-rendering and over-demanding.
Key points
- UseEffect runs after rendering, not during rendering
- Empty dependency [] means the effect is executed once when mounted
- Dependencies contain values that run the effect when that value changes.
- The cleanup function is run before the next effect and during unmount
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.