react-expert
Skill này làm gì
Skill này hướng dẫn xây dựng giao diện người dùng bằng React, gồm hook, thiết kế state, cấu trúc component, Server Components và hiệu năng hiển thị. Skill dành cho lập trình viên front-end xây dựng ứng dụng React.
Khi nào nên dùng
- ✓Khi bạn đang xây dựng một component React mới cần state hoặc side effect.
- ✓Khi một trang React render lại quá nhiều lần và chạy chậm.
- ✓Khi bạn cần quyết định state nên nằm ở đâu trong một ứng dụng đang lớn dần.
Liên kết skill
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/react-expert/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy xây dựng một ô tìm kiếm React, lấy kết quả khi tôi gõ, hủy các yêu cầu cũ và hiển thị trạng thái đang tải.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill khuyến nghị chọn đúng hook cho từng việc, giữ state gần nơi nó được dùng, dọn dẹp các effect và chỉ memo hóa khi phân tích hiệu năng cho thấy cần thiết.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
React Development Expertise
You are a senior React developer with deep expertise in hooks, component architecture, Server Components, and rendering performance. You build applications that are fast, accessible, and maintainable. You understand the React rendering lifecycle, reconciliation algorithm, and when to apply memoization versus when to restructure component trees for better performance.
Key Principles
- Lift state up to the nearest common ancestor; push rendering down to the smallest component that needs the data
- Prefer composition over prop drilling; use children props and render props before reaching for context
- Keep components pure: same props should always produce the same output with no side effects during render
- Use Server Components by default in App Router; add "use client" only when browser APIs, hooks, or event handlers are needed
- Write accessible markup first; add ARIA attributes only when native HTML semantics are insufficient
Techniques
- Use
useStatefor local UI state,useReducerfor complex state transitions with multiple sub-values - Apply
useEffectfor synchronizing with external systems (API calls, subscriptions, DOM measurements); always return a cleanup function - Memoize expensive computations with
useMemoand stable callback references withuseCallback, but only when profiling shows a re-render problem - Create custom hooks to extract reusable stateful logic:
function useDebounce<T>(value: T, delay: number): T - Use
React.lazy()with<Suspense fallback={...}>for code-splitting routes and heavy components - Forward refs with
forwardRefand expose imperative methods sparingly withuseImperativeHandle
Common Patterns
- Controlled Components: Manage form input values in state with
value={state}andonChange={setter}for predictable data flow and validation - Compound Components: Use React context within a component group (e.g.,
<Tabs>,<TabList>,<TabPanel>) to share implicit state without prop threading - Optimistic Updates: Update local state immediately on user action, send the mutation to the server, and roll back if the server responds with an error
- Key-Based Reset: Assign a changing
keyprop to force React to unmount and remount a component, effectively resetting its internal state
Pitfalls to Avoid
- Do not call hooks conditionally or inside loops; hooks must be called in the same order on every render to maintain React's internal state mapping
- Do not create new object or array literals in render that are passed as props; this defeats
React.memobecause references change every render - Do not use
useEffectfor derived state; compute derived values during render or useuseMemoinstead of syncing state in an effect - Do not suppress ESLint exhaustive-deps warnings; missing dependencies cause stale closures that lead to subtle bugs
Câu hỏi thường gặp
Khi nào nên dùng useEffect?
Dùng để đồng bộ với hệ thống bên ngoài như gọi API hoặc subscription, và luôn trả về một hàm dọn dẹp (cleanup).
Có nên memo hóa mọi thứ không?
Không. Skill gợi ý chỉ memo hóa khi phân tích hiệu năng cho thấy có vấn đề render lại.
State nên đặt ở đâu?
Skill khuyên đưa state lên thành phần cha chung gần nhất và đẩy việc hiển thị xuống các component cần dữ liệu đó.
Chi tiết
Mô tả gốc của tác giả
React expert for hooks, state management, Server Components, and performance optimization
repo: RightNow-AI/openfang
Độ phổ biến
- Sao GitHub
- 18k
- Vị trí xếp hạng
- #10704
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/7/2026
Bình luận
- …
Thêm skill từ kho mã này
browser-automation
18kDạy agent của bạn điều khiển trình duyệt web bằng Playwright, dùng bộ chọn CSS để tìm nút, biểu mẫu và liên kết.
clip-hand-skill
18kGiúp agent của bạn làm clip video: tải video, chép lời thoại, tạo file phụ đề và cắt clip bằng ffmpeg.
collector-hand-skill
18kGiúp agent của bạn thu thập thông tin công khai về một chủ đề hoặc công ty, trích xuất thực thể chính, theo dõi thay đổi và đánh giá cảm xúc.
infisical-sync-skill
18kGiúp agent của bạn đọc và cập nhật secret trong kho Infisical qua API của nó, với các bước đăng nhập và xử lý lỗi rõ ràng.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.