dev-proPRO
OverviewLộ Trình HọcPhỏng VấnAI System
dev-pro— Thực chiến Frontend React, Next.js & Luyện phỏng vấn
contact@dev-pro.online•Code thật. Phỏng vấn thật.
Seri React Mastery8 Lộ trình · Sandbox
Seri React Mastery
8 tracks
T01
React Core Foundations0/7 hoàn thành
T02
React Hooks Mastery0/5 hoàn thành
T03
React Component Architecture & Forms0/4 hoàn thành
T04
React & Compiler: Modern Path0/4 hoàn thành
T05
Form Engineering: RHF + Zod + Server Actions0/2 hoàn thành
T06
Advanced React Performance Patterns0/4 hoàn thành
  • Bài học (4)
  • React Concurrency: useTransition & useDeferredValue18m•advanced
  • Pattern Kiến Trúc: Compound Components & Inversion of Control20m•advanced
  • Kiến Trúc Quản Lý State Toàn Cục với Zustand v520m•intermediate
  • Profiling Hiệu Năng & Ảo Hóa Danh Sách (Virtualization)22m•advanced
T07
Enterprise React Testing & Production Readiness0/5 hoàn thành
T08
Production Capstone: TeamBoard0/1 hoàn thành
Tiến độ React0/32 bài
Advanced React Performance Patterns
advanced
20 phút
#Design Patterns
#Compound Components
#Inversion of Control
#UI Architecture

Pattern Kiến Trúc: Compound Components & Inversion of Control

Thiết kế hệ thống UI Component linh hoạt như các thẻ HTML nguyên bản (Select/Tabs/Accordion) bằng Compound Components và Context ngầm.

Core Mental Model

Compound Components tương tự như cặp thẻ `<select>` và `<option>` trong HTML: chúng chia sẻ state ngầm định với nhau nhưng cho phép lập trình viên tự do sắp xếp layout và JSX con theo ý muốn.

Key Takeaways & Principles

Tránh tạo ra 'God Component' với hàng chục boolean flags (`hasIcon`, `isSmall`, `showHeader`, `footerStyle`).
Compound Components sử dụng React Context nội bộ để giao tiếp giữa Component cha (Container) và các Component con (Item, Trigger, Content).
Inversion of Control (IoC) trao quyền quyết định cấu trúc và vị trí render cho người sử dụng component.