feat: Clarify keyed lists behavior
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- documentation
Hướng nghiên cứu
Bắt đầu với trang tài liệu Lists của lit-html được liên kết và xem lại phần thảo luận về Array.prototype.map(), keyed() và repeat(). Làm rõ hành vi được tài liệu mô tả và khuyến nghị dành cho các danh sách được sắp xếp lại, bao gồm cả phần so sánh liên quan với React và Stencil. Công việc được xem là hoàn tất khi trang này giúp người mới dễ dàng hiểu được sự khác biệt và lựa chọn dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[Regarding the page on lit-html Lists]
Coming from React and Stencil, I have been using this pattern in Lit:
myList.map(item=>
keyed(item.key, html`...`)
)
(which is similar to myList.map(item=><item key={item.key} ...> you would do in React and Stencil)
After reading Lit's source code, I realized that this is actually wrong and inefficient as it will not move the DOM nodes in response to myList items changing order, and instead re-create the DOM elements from scratch
- It might be just me, but explicitly calling out the above as wrong in the docs may be a good idea for transplants from other frameworks, and mentioning that
repeat()should be used instead- for new user this is a bit confusing - i.e why does
map()directive exists at all whenArray.prototype.mapdoes the job, and with less overhead? though a few other Lit directives likeifDefined()andwhen()are kind of needless API bloat too
- for new user this is a bit confusing - i.e why does
- Or better, would be nice if
lit-htmladds support for the above pattern and treats it equivalent to callingrepeat()(which, I can understand may be undesirable as it would require you to always bundlerepeat()even if not used).- As a workaround, for now I augmented my JSX->lit-html transformer to automatically convert code like
myList.map(item=><item key={item.key} ...>intorepeat(myList,item=>item.key,item=>html`<item ...>`
- As a workaround, for now I augmented my JSX->lit-html transformer to automatically convert code like
- Ngôn ngữ chính
- TypeScript
- Star
- 140
- Fork
- 229
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc 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.
Issue khác của lit/lit.dev
-
The example for `when` doesn't show that it takes the condition value as a parameterCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
GetStream/stream-chat-react#3467 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vercel-labs/ui#1139 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10Có thể đã có người làm @goranai đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] IntegerRange.contains counts a non-integer just above max as inside an inclusive rangeĐang mởbot:ai-assisted component:platform-js status:untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
midnightntwrk/platform-js#93 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100