Life cycle methods in a class component allow us to run code at particular points in the process. The following is a high-level diagram of the component process, showing when the different methods are invoked:
componentDidMount is invoked when a component has been inserted into the DOM. Here are some common use cases for this method:
- Calling a web service to get some data
- Adding event listeners
- Initializing timers
- Initializing third-party libraries
We're going to change the app we have been building to give users a time limit of 10 seconds to confirm whether or not they want to learn React and...