Hey little coder! ๐
In our last React session, we talked about what React is and why itโs amazing.
Now letโs dive deeper into the real heroes of React: components and props. ๐ฆธโโ๏ธ
These are like the bricks and glue that hold everything together in a React app.
๐งฉ What Are Components?
Think of components as tiny machines ๐ that you build once and use everywhere.
Like how you use a LEGO block to make different houses. ๐งฑ
In React, we have two main types of components:
Type | What it does | How it looks |
---|---|---|
Functional | Just a function that returns UI | Simple and clean |
Class-based | Older way with more features built-in | A bit longer |
๐ง Functional Components (The Modern Way)
These are simple functions that return JSX.
โ Example:
jsxCopyEditfunction Welcome() {
return <h2>Hi, Iโm a functional component! ๐</h2>;
}
Then render it like this:
jsxCopyEditReactDOM.render(<Welcome />, document.getElementById("root"));
Functional components are lightweight, easy to read, and perfect for beginners.
๐งโโ๏ธ Class Components (Old School)
Still useful for legacy apps, but less common today.
โ ๏ธ Slightly complex example:
jsxCopyEditclass Welcome extends React.Component {
render() {
return <h2>Hello from a class component! ๐งโโ๏ธ</h2>;
}
}
Use them when you need more control, like managing complex state (though we now use hooks instead in functional components).
๐ What are Props?
Props (short for properties) are how you pass data between components.
Letโs say you have a Greeting
component and want it to show different names.
๐ค Example:
jsxCopyEditfunction Greeting(props) {
return <h3>Hello, {props.name}! ๐</h3>;
}
Now use it like this:
jsxCopyEdit<Greeting name="Vikas" />
<Greeting name="Ananya" />
<Greeting name="Web Codder Fan" />
โ
This is called component reusability.
โ
You just used the same component 3 times with different data!
๐ฆ Visual: How Props Work

A parent passes data โก๏ธ child component receives it as props
๐ง Children in React
Sometimes, you want to pass whole elements inside a component.
Thatโs where children
come in.
Example:
jsxCopyEditfunction Wrapper(props) {
return <div className="box">{props.children}</div>;
}
<Wrapper>
<p>This is inside the box! ๐ฆ</p>
</Wrapper>
Here, props.children
means โwhatever you put between the opening and closing tags.โ
๐ฑ Default Props
Sometimes, you want to show default content if nothing is passed.
Example:
jsxCopyEditfunction Hello(props) {
return <p>Hello, {props.name}!</p>;
}
Hello.defaultProps = {
name: "Stranger",
};
So if you use <Hello />
without passing a name, it shows:
๐ Hello, Stranger!
๐ Breaking UI into Reusable Components
Big apps are hard to manage if everything is in one file. ๐
So letโs break them into smaller pieces.
Example: Building a profile card
jsxCopyEditfunction Avatar(props) {
return <img src={props.url} alt="Profile" />;
}
function Name(props) {
return <h4>{props.name}</h4>;
}
function ProfileCard() {
return (
<div className="card">
<Avatar url="https://via.placeholder.com/150" />
<Name name="Vikas Sankhla" />
</div>
);
}
๐ Now each part (Avatar and Name) is its own component.
Easy to maintain and reuse in other parts of your app.
โ๏ธ Props vs State (Quick Preview)
Letโs keep this simple:
Feature | Props | State |
---|---|---|
Purpose | Pass data from parent | Store data inside component |
Mutable? | โ No (read-only) | โ Yes (can change) |
Who sets it? | Parent component | Component itself |
We’ll learn state more in the next part ๐
๐ง Key Concepts Recap
Concept | What It Means |
---|---|
Component | A piece of the UI you can reuse |
Functional Component | A simple function that returns JSX |
Props | Data passed from parent to child |
Children | Elements passed inside a component |
Default Props | Fallback values if no prop is passed |
Reusability | Using the same component in many places |
๐ง Mind Map: Components + Props

Visually showing: App โ Parent โ Child โ Props โ JSX โ Reuse
๐ Letโs Keep Learning Together!
If you’re loving this React series, donโt forget to support Web Codder! ๐
- ๐บ YouTube: Subscribe Now
- ๐ธ Instagram: @web_codder_official
- ๐ฌ WhatsApp Community: Join here
Your support keeps this free content coming! ๐
๐ Final Words
React becomes easier once you understand components and props.
Theyโre the LEGO blocks ๐งฑ of your app โ build small, combine big.
Iโm Vikas Sankhla from Web Codder โ your tech buddy!
Until next time, keep building, keep breaking (code only ๐), and stay curious.