Hackforge Academy

Category: react

state and props

Published on 26 May 2026

Explanation

State in React is used to store and manage dynamic data inside a component.

Code:

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

Explanation

Props are used to pass data from a parent component to a child component.

Code:

<User name="Praveen" />

Explanation

State can be updated using the setter function returned by useState().

Code:

setCount(count + 1);

Explanation

Props are read-only and cannot be modified inside the child component.

Code:

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

Explanation

State manages internal component data, while props help components communicate with each other.

Code:

Parent Component --> Props --> 
Child Component

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community