example/: kitchen-sink demo cannot be installed, and its Suspense path cannot run
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 55/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Calme
- Stack technique
- react, typescript
- Domaine
- build-system, frontend
Piste de recherche
Commencez par example/package.json et son fichier de verrouillage, puis examinez example/index.tsx:45 et example/withSuspense/Firestore.tsx:2,87. Effectuez d’abord une installation propre dans example/ et déterminez si la démo doit utiliser le workspace, une archive tarball générée ou une version publiée ; c’est terminé lorsque les dépendances s’installent et que le chemin Suspense se compile et s’exécute sans les échecs React 17/18 décrits.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 3.6k
- Forks
- 403
- Merge moyen
- 5 j 1 h
- PR mergées (30 j)
- 10
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de FirebaseExtended/reactfire
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 38/100
FirebaseExtended/reactfire#801 ·
-
v5
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
FirebaseExtended/reactfire#793 ·
-
v5
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
FirebaseExtended/reactfire#790 · 2 commentaires ·
-
v5
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
FirebaseExtended/reactfire#789 ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
FirebaseExtended/reactfire#788 ·
Toutes les issues de FirebaseExtended/reactfire
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
bcgov/bc-wallet-mobile#4761 · 1 commentaire ·
-
external-issue to-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
area-deployment area-integrations triage:bot-seen
Difficulté 2/5 Une demi-journée Accessibilité débutants 86/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
refactor
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100