React Fundamentals & Your First Component
What Are Components?
Your First Component: The Product Card
Step 1: A Static Component
// ProductCard.tsx
import React from 'react';
function ProductCard() {
return (
<div className="product-card">
<h3>Mohinga</h3>
<p className="price">3500 MMK</p>
<p className="stock">In Stock: 24</p>
<p className="category">Breakfast</p>
</div>
);
}
export default ProductCard;Understanding JSX
Props: Making Components Reusable
Step 2: Component with Props
Destructuring Props (Cleaner Syntax)
Conditional Rendering
Component Composition
Adding Styles
Option 1: CSS Modules (Recommended for larger apps)
The Complete Picture: Types and Real Data
Key Learnings
β
Components Are Just Functions
β
Props Make Components Reusable
β
JSX Is JavaScript
β
Composition Over Complexity
β
TypeScript Saves Time
Common Mistakes I Made (So You Don't Have To)
Next Steps
Last updated