React useEffect: How the Dependency Array Controls When Side Effects Run
The article explains useEffect, a React hook for handling side effects such as fetching API data, setting timers, adding event listeners, and updating the browser tab title. It describes the hook's basic syntax, which takes a callback and a dependency array. Three patterns are covered: an empty array runs the effect once after mount, a dependency like count runs it on mount and whenever that value changes, and omitting the array runs it after every render. A complete counter component is included to demonstrate the behavior in practice.








