opendevs
Prevent infinite updates in useEffect

Cleanup in useEffect

Dogendar 🐶 has a cleanup obsession - he always try to put things back where they were once he's done playing.

Today, he wants to play with the title of the page (it's the text that you see in the browser tab). He wants to set the page title to Dev11 when the React component mounts and once he's bored and wants to close the app (unmount the component), he wants to restore the original page title, i.e. set the page title to what it was initially.

Help Dogendar finish the component and fulfil these requirements:

  • Set the page title to Dev11 when the component mounts
  • Restore the original page title when component unmounts

Difficulty

medium

Solve the practice problems to earn    DevCoin image 
Coding Area
Output

Copyright © 2022 opendevs

Learn ● Develop ● Ace
All illustrations by Storyset