Let's create a basic example so that you may visualise how React's Lifecycle Methods work in practice.
npx create-react-app react-lifecycles-example
cd react-lifecycles-example
code .
Your src
folder after creating the new component should look like this:
📦src
┣ 📂components
┃ ┗ 📜Counter.js
┣ 📜App.css
┣ 📜App.js
┣ 📜App.test.js
┣ 📜index.css
┣ 📜index.js
┣ 📜logo.svg
┗ 📜serviceWorker.js
4. Update the src/App.js
by replacing the inital code copy/pasting the code from the below App.js
snippet.
npm start
Take a look at your Chorme Dev console, you should find the following result: