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

use `MultiProvider` with arbitrary props and not only `value: T`

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

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

Chưa có ai nhận issue này.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu bằng cách đọc các entry point MultiProvider và createContextProvider cùng với các định nghĩa prop TypeScript của chúng. Kiểm tra cách MultiProvider truyền giá trị hiện tại của từng context, sau đó xác minh rằng các context được tạo với các prop tùy ý như { initial: 1 } có thể được cung cấp mà không cần bọc chúng trong { value: ... }.

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

Mô tả

enhancement help wanted
Describe The Problem To Be Solved

The Context primitive adds functionality to easily create context providers through createContextProvider. Given the example code on the website, ...

const [CounterProvider, useCounter] = createContextProvider((props: { initial: number }) => {
  const [count, setCount] = createSignal(props.initial);
  const increment = () => setCount(count() + 1);
  return { count, increment };
});

// Provide the context
<CounterProvider initial={1}>
  <App />
</CounterProvider>;

... the following code does not work when paired with the MultiProvider as it only accepts a single argument value:

<MultiProvider
  values={[
    [CounterProvider, { initial: 1 }] // not working, as this is passed to the single `value` field.
  ]}
>
  <App />
</MultiProvider>;
Suggest A Solution

It would be nice if the individual contexts of MultiProvider accepted the same props as returned from createContextProvider so they seamlessly work together. A workaround would be to wrap the context props with { value: ContextProps }, but this destroys usability and requires refactoring the entire codebase

Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
162
Merge trung bình
1 giờ 20 phút
Pull request đã merge (30 ngày)
7

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 solidjs-community/solid-primitives

Tất cả issue của solidjs-community/solid-primitives

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.