From the course: Building React and Django Apps
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Using timers with state to display data
From the course: Building React and Django Apps
Using timers with state to display data
- [Narrator] Whenever the user in on the checkout page, we want to introduce some urgency that they should place the order. We can do this with a countdown. When the component is mounted, we create a timer that counts down every second. If the user switches the page, the countdown is cleared. When they come back to the page, it'll be reset. The component does not render when time has run out. That while the countdown is on, it shows a message. Now on the checkout page, we import that component and we add it to the render method, specifically the checkout summary section. And it's a one minute countdown. Now let's run the dev servers. Let's reserve a package. And we can see that the countdown has begun.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.