React useState vs Normal Variables: Why State Triggers Re-Renders

💡 Interview Question: “Why do we use useState when we can store data in variables?” This is a very common React / React Native interview question, and the answer shows how well you understand React fundamentals. 👉 Short answer: Because normal variables do NOT trigger re-render, but useState does. 🔍 Explanation: • In React, the UI is a function of state + props • If you update a normal variable, React doesn’t know that anything changed • So the UI will not update • But when you update state using useState, React: ✅ Tracks the change ✅ Re-renders the component ✅ Updates the UI automatically 🚀 Why useState is important: ✔ Triggers component re-render ✔ Keeps UI and data in sync ✔ Preserves values between renders ✔ Core concept for building dynamic UIs 📌 Interview Tip: If React doesn’t re-render, your UI is already broken — that’s why state exists. ⸻ 💬 Have you faced this question in interviews? Drop your experience below 👇 #ReactJS #ReactNative #JavaScript #FrontendDevelopment #WebDevelopment #MobileAppDevelopment #CodingInterview #ReactHooks #useState #SoftwareEngineering #TechInterview #DeveloperLife #LearningReact

  • graphical user interface, text, application, email

To view or add a comment, sign in

Explore content categories