Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add a shared useControllableState hook

Đang mở
#876 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@Shreyag02 đang làm issue này rồi.

Từ ngày 11/10/2026.

  • #966 của @Shreyag02 — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
68/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu trong packages/raystack/hooks và so sánh các mẫu controlled/uncontrolled trong sidebar-root.tsx, select-root.tsx và data-view.tsx. Đọc mô hình @radix-ui/react-use-controllable-state được tham chiếu, sau đó xác minh rằng Sidebar, Select và DataView sử dụng các ngữ nghĩa dùng chung một cách nhất quán.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement global

Summary

Components that support both controlled and uncontrolled usage each re-implement the controlled/uncontrolled merge by hand, with a slightly different shape every time. There's no shared hook for it in packages/raystack/hooks.

Current duplication

  • sidebar-root.tsx:128-129 — const [internalOpen, setInternalOpen] = useState(defaultOpen); const open = providedOpen ?? internalOpen;
  • select-root.tsx:113-122 — same ?? pattern, duplicated again for searchValue a few lines later.
  • data-view.tsx:73-83 — different style again: explicit isViewControlled = view !== undefined boolean instead of ??.

Components built directly on Base UI primitives (Checkbox, Switch, Tabs, Accordion, Dialog) don't have this problem — they get controlled/uncontrolled handling for free from Base UI. This only affects components with custom root logic.

Suggested approach

Add one useControllableState({ value, defaultValue, onChange }) hook to packages/raystack/hooks, modeled on @radix-ui/react-use-controllable-state. Migrate Sidebar, Select, and DataView onto it so all three follow the same merge semantics.

Notes

Found via a components.build practices audit (state management dimension).

Ngôn ngữ chính
TypeScript
Star
69
Fork
13
Merge trung bình
3 ngày 15 giờ
Pull request đã merge (30 ngày)
24

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của raystack/apsara

Tất cả issue của raystack/apsara

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.