Module 3 · Lesson 4 ⏱ 18 min

React Hooks: useState & useEffect

In this lesson, you'll master React's two most essential hooks. We'll build real interactive components and understand the component lifecycle.

Key Concepts

  • useState — Adds local state to a function component. Returns current state + updater function.
  • useEffect — Runs side effects after render. Replaces componentDidMount and componentDidUpdate.
  • Dependency Array — Controls when the effect re-runs. Empty array = run once on mount only.
  • Cleanup Function — Return a function from useEffect to clean up subscriptions or timers.

Discussion (12 comments)