[2.0 rc.14] Docs: what a pending <Loading> subtree computes, commits and runs, so a view can be preloaded by rendering it
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 32/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
The request is about the boundaries documentation page, which the issue says covers only when <Loading> shows its fallback. Start by reading that page, then run the issue's reproduction (the gated and plain buttons) to confirm the three behaviours: children keep computing, a pending boundary never commits or runs effects, and a never-settling promise memo keeps it pending. Done means the page either documents those three points as supported with the preloading case as an example, or states which are not guaranteed. The maintainers need to decide which, so check with them before writing the text.
由索引模型根据 Issue 内容生成。
描述
Summary
A view's data can be preloaded without listing what it reads: render it into a detached element inside a <Loading> held pending by a promise that never settles. Every read in its tree then starts, level by level as data arrives, while nothing is committed and no effect runs. This works on rc.14, but the docs don't describe any of the behaviour it depends on, so it may change without notice. This asks for that behaviour to be documented as supported, or for the docs to say it isn't.
Reproduction
A page with a list and one detail per row. run(true) renders it into a detached element behind a never-settling gate; run(false) renders the same tree without the gate, as a control.
import { render } from "@solidjs/web";
import {
createEffect,
createMemo,
For,
getOwner,
Loading,
onSettled,
runWithOwner,
} from "solid-js";
const t0 = performance.now();
const log: string[] = [];
const stamp = (entry: string) => log.push(`${Math.round(performance.now() - t0)}ms ${entry}`);
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
async function load<T>(name: string, value: T) {
stamp(`load ${name}`);
await delay(100);
return value;
}
function Detail(props: { id: string }) {
const detail = createMemo(() => load(`detail:${props.id}`, `detail ${props.id}`));
return <p ref={() => stamp(`element detail:${props.id}`)}>{detail()}</p>;
}
function Page() {
const list = createMemo(() => load("list", ["a", "b"]));
createEffect(
() => list(),
() => {
stamp("effect ran");
},
);
onSettled(() => {
stamp("onSettled ran");
});
return (
<ul ref={() => stamp("element list")}>
<For each={list()}>
{(id) => (
<li>
<Detail id={id} />
</li>
)}
</For>
</ul>
);
}
function run(gated: boolean) {
log.length = 0;
const host = document.createElement("div");
const dispose = runWithOwner(owner, () =>
render(() => {
const gate = createMemo(() => new Promise<never>(() => {}));
return (
<Loading fallback={null}>
{gated ? gate() : null}
<Page />
</Loading>
);
}, host),
);
setTimeout(() => {
console.log(log, host.innerHTML);
dispose();
}, 600);
}
let owner: ReturnType<typeof getOwner> = null;
export default function App() {
owner = getOwner();
return (
<main>
<h1>preview</h1>
<button type="button" onClick={() => run(true)}>
gated
</button>
<button type="button" onClick={() => run(false)}>
plain
</button>
</main>
);
}
Measured in headless Chromium under vite dev (times from run()):
| Loads started | Elements created (ref ran) |
Committed to the host | createEffect / onSettled |
Console | |
|---|---|---|---|---|---|
| gated | list at 0 ms, detail:a/detail:b at 103 ms |
ul, both p |
no (host empty) | never ran | nothing |
| plain | list at 0 ms, detail:a/detail:b at 105 ms |
ul, both p |
yes | ran at 208 ms | nothing |
What is undocumented
The boundaries page describes only when a <Loading> shows its fallback. The pattern above depends on three things it doesn't say:
- The children of a pending
<Loading>keep computing, and reads discovered as data arrives start too. - A pending boundary never commits its children or runs their effects (
createEffect,onSettled), however long it stays pending. - A memo whose value is a promise that never settles is an acceptable way to keep a boundary pending, without a diagnostic now or later.
Request
Document these three points as supported behaviour, for example on the boundaries page with this preloading use as the example, or say which of them is not guaranteed.
A primitive that does the same without building the DOM is requested in #3975.
(submitted by Claude Opus 5.5 on behalf of rvlzzr)
- 主要语言
- TypeScript
- 星标
- 36.1k
- 派生
- 1.1k
- 平均合并
- 11 小时 34 分钟
- 30 天内合并 PR
- 341
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
[diagnostics rc.14 / next] Browser bridge drops shared references, so `expectNoSilentHolds` throws on any capture with a `LONG_HOLD`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 12/100
维护者通常 1 天内回复
-
[2.0 rc.14 / next] SSR: async memo retries run under another concurrent render's context可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 52/100
维护者通常 1 天内回复
-
hydrate() run mid-parse leaves dead server nodes beside fresh client copies (async entry script)未关闭
难度 4/5 3-5 天 新手友好度 20/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
Agenta-AI/agenta#7542 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
code quality security
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 90/100
-
难度 1/5 1 小时以内 新手友好度 82/100
homarr-labs/dashboard-icons#2939 ·
维护者通常 1 天内回复