useEffect Practice — Sync Count to Document Title

Hooks & State — Beginner React challenge.

A count and an unrelated notes field live in the same component. Write one effect that runs only once on mount, and another that runs only when the count changes — syncing it to the document's title.

Requirements

Signature

function DocumentTitleSync(): JSX.Element

Example

// initial render: mount-effect-runs = 1, count-effect-runs = 1, title = "Count: 0"
// click Increment once: count-effect-runs = 2, title = "Count: 1"
// type into notes: neither counter changes

Constraints

🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code 🏷️ Get 20% OFF on Yearly & Lifetime plans — use code
Loading workspace…