TGViewer
Web Development Web Development @web_dev_bds Β· 4.44K subscribers
Post #805 600
βš›οΈ React: State vs. Props πŸ”„

In React, data moves through components via Props and State. Confusing these two is the #1 cause of bugs in frontend apps.


πŸ”Ή 1. What are Props? (The "Input")
Props is short for "properties." They are passed from parent to child (like arguments to a function). Props are read-only; a component cannot change its own props.

Example:
// Parent
<User name="Alice" />

// Child
function User(props) {
return <h1>Hello, {props.name}</h1>;
}

πŸ”Ή 2. What is State? (The "Memory")
State is internal to a component. It stores data that changes over time (like text in an input or a counter). When state changes, the component re-renders.

Example:
const [count, setCount] = useState(0);

return <button onClick={() => setCount(count + 1)}>{count}</button>;

πŸ”Ή 3. Key Differences
β€’ Props: External, passed down, immutable (can't be changed).
β€’ State: Internal, managed within, mutable (via updater function).

πŸ‘‰ Think of Props as the "Settings" and State as the "Current Status" of your component.

🎯 What you should do

βœ”οΈ Understand that data flows down (Props)
βœ”οΈ Use State for data that changes
βœ”οΈ Avoid trying to modify props directly
  • ❀ 3
More from @web_dev_bds
  1. Oct 13, 2026Docker vs Kubernetes
  2. Oct 12, 2026Post #1054
  3. Oct 11, 2026CSS Tip Stop centring tooltips with πšπš›πšŠπš—πšœπš•πšŠπšπšŽ: -𝟻𝟢%. near the edge of the scree…
  4. Oct 9, 2026JavaScript CheatSheet
  5. Oct 8, 2026πŸ“•Pro tip if you're using Postgres: Set `application_name` in your app's DB connector/ORM/…
  6. Oct 7, 2026πŸš€ Beginner β†’ Developer: What to Learn in 6 Months Want to become job-ready but don't know…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’