State
الحالة (State)
GLS-000077
Definition
Data that changes over time and causes the UI to update when it changes.
البيانات التي تتغير بمرور الوقت وتُحدّث الواجهة عند تغيّرها.
Why It Matters
State is the core concept that makes React apps dynamic. Without state, a React component is just static HTML. Understanding state is required to build any interactive feature.
State هو المفهوم الأساسي الذي يجعل تطبيقات React ديناميكية. بدون state، مكوّن React مجرد HTML ثابت. فهم state ضروري لبناء أي ميزة تفاعلية.
Full Definition
Example Usage
“const [bookmarked, setBookmarked] = useState(false) tracks whether a project is bookmarked. Clicking the icon calls setBookmarked(true) and React re-renders the icon as filled.”
“const [bookmarked, setBookmarked] = useState(false) يتتبع ما إذا كان المشروع محفوظًا في الإشارات المرجعية. النقر على الأيقونة يستدعي setBookmarked(true) وReact يُعيد تصيير الأيقونة كمملوءة.”
AI Builder Tips
Avoid these mistakes when using State:
Mutating state directly instead of using the setter function
Storing derived data in state instead of computing it
Overusing global state for things that can stay local
Sign in to unlock guided AI explanations from AI Teacher.
Generate a Prompt
Copy this prompt and use it directly with any AI model — no setup needed.
Help me build a project using State. Explain: 1. What is State and why it matters 2. The core architecture and required tools 3. Step-by-step implementation plan 4. Common mistakes to avoid: Mutating state directly instead of using the setter function, Storing derived data in state instead of computing it, Overusing global state for things that can stay local 5. Best practices and production tips