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
  • Bài học (4)
  • Quy chuẩn Viết Custom Component & Typescript (Enterprise)15m•intermediate
  • Chuyên sâu Form: Controlled vs Uncontrolled Components18m•intermediate
  • Tối ưu Memoization thủ công: useMemo & useCallback15m•intermediate
  • Khoanh vùng lỗi với React Error Boundary & Next.js error.tsx18m•advanced
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
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
React Component Architecture & Forms
intermediate
18 phút
#Forms
#Controlled
#Uncontrolled
#useRef

Chuyên sâu Form: Controlled vs Uncontrolled Components

Phân tích ưu/nhược điểm, khi nào dùng useRef vs useState và các bế tắc (Issues) của Form truyền thống.

Core Mental Model

Controlled Form = React giữ quyền kiểm soát State ở từng keystroke. Uncontrolled Form = Trình duyệt (DOM) giữ quyền kiểm soát value, React chỉ đọc qua useRef.

Key Takeaways & Principles

Controlled Component (useState + onChange): Phù hợp cho realtime input validation, dynamic field masking, dependent inputs. Nhược điểm: Re-render component ở MỌI phím gõ.
Uncontrolled Component (useRef + FormData): giá trị nằm trong DOM nên mỗi phím gõ không tự lên lịch React render. Phù hợp khi chỉ cần đọc dữ liệu lúc submit; live validation và đồng bộ UI sẽ khó hơn.
Bế tắc của Form truyền thống: (1) Form lớn 100 inputs bị giật lag re-render; (2) Xử lý pending status thủ công tốn code; (3) Server validation error mapping phức tạp; (4) Không có JS thì form hỏng.
Giải pháp React: Dùng Form Actions + useActionState kết hợp ưu điểm của cả 2 mô hình!