Language switching UI
📖 Scenario: You are building a simple website that supports switching between English and Spanish languages. Users can click buttons to change the displayed greeting message.
🎯 Goal: Create a Next.js functional component that shows a greeting message in English or Spanish. Add buttons to switch the language dynamically.
📋 What You'll Learn
Create a React functional component named
LanguageSwitcherUse
useState hook to store the current languageDisplay a greeting message that changes based on the selected language
Add two buttons labeled
English and Spanish to switch languagesUpdate the greeting message immediately when a button is clicked
💡 Why This Matters
🌍 Real World
Language switching is common in websites to support users from different countries. This UI lets users pick their preferred language easily.
💼 Career
Understanding how to manage state and update UI in React is essential for frontend developers building interactive web apps.
Progress0 / 4 steps