[Suggestion]: Document using Promises passed from RSC to the client without `use()`
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 11.8k
- Fork
- 7.9k
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 11
Mô tả
Summary
The docs on RSC should mention whether Promises passed from Server Components can be used without use().
Page
https://react.dev/reference/rsc/server-components
Details
Currently, the docs only discuss resolving Promises passed from the server using use(). Sometimes it can be useful to render a component with partial data and update its state once the promise is fulfilled. This appears to work.:
"use client";
export default function Component({ promise }) {
const [data, setData] = useState(null);
useEffect(() => {
let canceled = false;
promise.then((d) => !canceled && setData(d));
return () => canceled = true;
}, [promise])
return (<p>{data}</p>);
}
However I can't find any mentions of this use case. I think that if this is officially supported, there should be an example showing how to do it. And if not, that should be explicitly stated.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với trang Server Components tại https://react.dev/reference/rsc/server-components và xem lại phần thảo luận hiện tại về Promises được truyền cho client components. Xác định xem trường hợp sử dụng được nêu có được chính thức hỗ trợ hay không, sau đó ghi lại bằng một ví dụ hoặc nêu rõ rằng trường hợp này không được hỗ trợ. Hoàn thành có nghĩa là trang đề cập rõ ràng đến trường hợp sử dụng này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, react
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100