Class 02: ReactJS Component
Giới thiệu về Component trong React
Cách tạo Function Component bằng TypeScript
Cú pháp cơ bản
// app/components/Hello.tsx
'use client';
import React from 'react';
const Hello = () => {
return <h1>Chào mừng đến với React + TypeScript + Next.js!</h1>;
};
export default Hello;Lưu ý
Tạo Component có Props với TypeScript
Ví dụ component nhận props
Cách sử dụng component có props
Truyền children cho Component
children cho ComponentVí dụ component layout dùng children
childrenCách sử dụng
Tái sử dụng Component qua danh sách .map()
.map()Ví dụ hiển thị danh sách sản phẩm
Bài tập thực hành cho học viên
Bài tập 1: Tạo component ProfileCard
ProfileCardBài tập 2: Tạo component Button có thể tái sử dụng
Button có thể tái sử dụngTổng kết
Last updated