[signals] A guessed row remounts when the truth lands from a local source store, even with the same id
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/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
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
The issue provides a TypeScript reproduction using createOptimisticStore, createStore, and mapArray, but names no source or test file. Start by locating the optimistic store implementation and its tests, then reproduce the local source store case and compare it with the fetch plus refresh() case. Done means the same-id row mounts once and updates pending in place for both forms, while different ids still remount.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
An action adds a row optimistically, then writes the saved row into the source of truth. The guess reverts and the saved row shows in the same frame, with no blink. But when the optimistic store is derived from a local store (createOptimisticStore(() => source, [])), the keyed list remounts the row, even when the saved row has the same id as the guess.
When the truth comes from a fetch instead (createOptimisticStore(async () => fetchTodos(), []) plus refresh() in the action), the same steps keep the row. It mounts once and updates in place. Only the local-source form drops it.
Found on main @ 8bfca0d while answering #5129.
Repro
const [source, setSource] = createStore<Todo[]>([]);
const [todos, setTodos] = createOptimisticStore<Todo[]>(() => source, []);
createRoot(() => {
const rows = mapArray(() => todos, row => {
console.log("mount", row.id);
createRenderEffect(() => `${row.id}:${!!row.pending}`, v => console.log("row", v));
return row;
});
createRenderEffect(() => rows().length, () => {});
});
let resolveSave!: (t: Todo) => void;
const add = action(function* (text: string) {
setTodos(t => { t.push({ id: "tmp-1", text, pending: true }); }); // guess
const saved: Todo = yield new Promise<Todo>(r => (resolveSave = r));
setSource(s => { s.push(saved); }); // truth
});
add("milk");
// flush, then:
resolveSave({ id: "tmp-1", text: "milk" }); // the server kept the client's id
Observed
| Truth | Same id |
Different id |
|---|---|---|
Local source store, setSource in the action |
mount tmp-1, then mount tmp-1 again |
remounts |
Fetch plus refresh() in the action |
one mount tmp-1; the row flips pending true → false in place |
remounts |
Every case ends on the right value.
Expected
With the same id, the guess row carries over to the saved row in both forms, as it does in the fetch form. The local form looks like it adopts source's own row proxies instead of reconciling them by key, so the guessed row is dropped and a new one is mounted.
- Ngôn ngữ chính
- TypeScript
- Star
- 37k
- Fork
- 1.2k
- Merge trung bình
- 8 giờ 43 phút
- Pull request đã merge (30 ngày)
- 365
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 solidjs/solid
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[2.0.4] Nested `<Errored>`: the outer boundary stays on an error the inner one rethrew, after the next error is one the inner one handlesCó thể đã có người làm @MilindChatrabhuji đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid
Issue tương tự
-
agentscan:mixed-signals pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vueuse/vueuse#5737 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 9 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Marker-Inc-Korea/AutoRAG#2288 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Resources: New templates of Guangzhou Metro Line 13Có thể đã có người làm @rmt-svc đã nhận hôm nay. Đang mởresources
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
railmapgen/rmg-templates#2730 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
web
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày