Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)18k · #10704

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.md

Sao 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

Hãy dùng skill này để giúp tôi: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/react-expert/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

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 useState for local UI state, useReducer for complex state transitions with multiple sub-values
  • Apply useEffect for synchronizing with external systems (API calls, subscriptions, DOM measurements); always return a cleanup function
  • Memoize expensive computations with useMemo and stable callback references with useCallback, 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 forwardRef and expose imperative methods sparingly with useImperativeHandle

Common Patterns

  • Controlled Components: Manage form input values in state with value={state} and onChange={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 key prop 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.memo because references change every render
  • Do not use useEffect for derived state; compute derived values during render or use useMemo instead 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

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự