Traffic Light Component in React

Опубликовано: 30 Май 2026
на канале: Project Santanu
142
4

In this tutorial, we tackle a common interview question: How to build a traffic light component in React? We'll guide you through the process step-by-step, from setting up your React project to implementing the traffic light logic and styling it using CSS. Whether you're new to React or looking to expand your skills, this tutorial provides a comprehensive understanding of building components in React. Watch now and level up your React development skills!

Question

Build a traffic light where the lights switch from green to yellow to red after predetermined intervals and loop indefinitely. Each light should be lit for the following durations:
Red light: 4000ms
Yellow light: 500ms
Green light: 3000ms
You are free to exercise your creativity to style the appearance of the traffic light.