example/: kitchen-sink demo cannot be installed, and its Suspense path cannot run
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- react, typescript
- 领域
- build-system, frontend
调研方向
从 example/package.json 及其 lockfile 开始,然后检查 example/index.tsx:45 和 example/withSuspense/Firestore.tsx:2,87。首先在 example/ 中进行一次干净安装,并确定 demo 应使用 workspace、生成的 tarball 还是已发布的版本;当依赖项安装成功,并且 Suspense 路径能够构建和运行而不出现所述的 React 17/18 失败时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Two pre-existing defects in example/, both surfaced by @armando-navarro while reviewing #781 and both verified against main. Neither was caused by that PR and neither was fixed by it, so they are filed here rather than left in a review thread on a merged PR.
They are filed together because the fix for the second requires the first: there is no way to check that the Suspense path runs without being able to install the demo.
1. The demo cannot be installed as checked out
example/package.json depends on:
"reactfire": "file:../reactfire-4.0.1.tgz"
That tarball is not in the repository, so npm install inside example/ fails from a clean checkout. Whatever produced it was never committed and no script regenerates it.
Worth deciding rather than patching blindly: the fix could be a file:.. reference to the workspace, a documented npm pack step, or a published version range. They differ in whether the demo is meant to exercise the local working tree or the last release.
2. The Suspense path cannot run, on either the old instructions or the new ones
example/index.tsx ships a commented-out Suspense variant. #781 corrected the comment to say the path does not run as checked in, which is accurate, but the underlying reason is worth recording.
example/package.json pins the runtime to React 17 while the types are already on 18:
"react": "^17.0.0",
"react-dom": "^17.0.0",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"typescript": "^4.7.4"
That skew produces two distinct failures.
example/index.tsx:45, the commentedReactDOM.createRoot(rootElement). On react-dom 17 this isundefinedat runtime, and under@types/react-dom@18it is also a type error, becausecreateRootis declared inclient.d.tsand not on the root entry. The example'sbuildistsc && vite build, so uncommenting it breaks the build as well as the app.example/withSuspense/Firestore.tsx:2, which importsuseTransition(used at:87). This one type-checks cleanly because@types/reactis already 18, and fails only at runtime on React 17. It is the more dangerous of the two for exactly that reason.
Those are the only React 18 APIs anywhere under example/, which bounds the work:
example/index.tsx:45: // ReactDOM.createRoot(rootElement).render(
example/withSuspense/Firestore.tsx:2: import { useState, useTransition } from 'react';
example/withSuspense/Firestore.tsx:87: const [isPending, startTransition] = useTransition();
The instructions that #781 replaced did not work either. Verified on react@experimental: createRoot, unstable_createRoot and render are all undefined on the root react-dom entry. So this is long-standing, and #781 regressed nothing.
What the fix involves
- Bump
reactandreact-domto 18 inexample/package.json, and the lockfile. - Import
createRootfromreact-dom/client, not the root entry. It is not on the root entry under@types/react-dom@18either, so the currently commented specifier would still be wrong after the bump. - Word the comment as replacing the existing
ReactDOM.rendercall, not uncommenting alongside it. Leaving both produces React 18'sYou are calling ReactDOMClient.createRoot() on a container that was previously passed to ReactDOM.render()warning. - Rename
ConcurrentModeApp/NonConcurrentModeApp. "Concurrent mode" has not been the name for this since React 18 shipped, and #781 removed that framing from the surrounding prose but deliberately left the identifiers, since renaming them is not a comments-only change.
#781 also deliberately left the commented ReactDOM.createRoot specifier uncorrected. Fixing it in isolation would make the block look runnable, which is the opposite of what the caveat it sits under is for. It should be corrected as part of the bump, not before.
Not a ReactFire bug
Worth stating explicitly so this is not mistaken for a library problem: ReactFire itself works fine on React 17. @armando-navarro ran useObservable with suspense: true under the legacy render path and it suspends, resolves and keeps updating. The React 18 requirement belongs to the demo, not to the library.
Refs #781.
- 主要语言
- TypeScript
- 星标
- 3.6k
- 派生
- 403
- 平均合并
- 5 天 1 小时
- 30 天内合并 PR
- 10
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
FirebaseExtended/reactfire 的其他 Issue
-
难度 5/5 一周以上 新手友好度 38/100
FirebaseExtended/reactfire#801 ·
-
v5
难度 4/5 3-5 天 新手友好度 48/100
FirebaseExtended/reactfire#793 ·
-
v5
难度 4/5 3-5 天 新手友好度 35/100
FirebaseExtended/reactfire#790 · 2 条评论 ·
-
v5
难度 4/5 3-5 天 新手友好度 55/100
FirebaseExtended/reactfire#789 ·
-
难度 5/5 一周以上 新手友好度 35/100
FirebaseExtended/reactfire#788 ·
查看 FirebaseExtended/reactfire 的全部 Issue
相似的 Issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
-
Crush 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
catppuccin/catppuccin#3125 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
ElementsProject/cln-application#167 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Quantco/pnpm-licenses#17 ·
-
难度 2/5 1-3 小时 新手友好度 75/100