My First Steps in Learning React
When I started web development, I knew HTML, CSS, and basic JavaScript. I could build simple websites, but when projects became bigger, I started facing problems. I repeated the same code many times, and managing everything became difficult.
Then I started learning React. At first, it was confusing, but slowly I understood the basics and it became easier.
What is React?
React is a JavaScript library used to build user interfaces. It was created by Facebook.
In simple words, React helps us build websites by dividing them into small parts called components. Each component handles one part of the page like header, footer, or content.
Why use React?
React makes development easier and cleaner.
- It helps to organize code
- It allows reusing components
- It is easy to update and maintain
- It improves performance
React updates only the changed part of the page, so it is faster than normal websites.
What is a Reusable Component?
Reusable component means writing code once and using it many times.
Instead of repeating code like this:
<button>Click</button>
<button>Click</button>
<button>Click</button>
We can create one component:
function Button() {
return <button>Click</button>;
}
And reuse it:
<Button />
<Button />
<Button />
This makes code simple and clean.
Using Reusable Components in a Blog
In a blog, every post looks similar. So we can create one component and reuse it.
function PostCard(props) {
return (
<div>
<h2>{props.title}</h2>
<p>{props.content}</p>
</div>
);
}
Now use it like this:
<PostCard title="React Basics" content="Learning step by step" />
<PostCard title="JavaScript Tips" content="Practice daily" />
This saves time and avoids repetition.
SPA and MPA
SPA means Single Page Application. It loads one page and updates content without reloading. React uses this method, so it feels fast.
MPA means Multi Page Application. It loads a new page every time we click something. It is slower compared to SPA.
Main difference:
SPA does not reload page, MPA reloads page every time.
Library and Framework
A library is a tool that helps us do specific tasks. We control how to use it. React is a library.
A framework is a full structure for building applications. It controls the flow. Examples are Angular and Django.
Main difference:
In a library, we control the code. In a framework, the framework controls everything.
Top comments (0)