preact
preact copied to clipboard
Fix Suspense Hydration
Instead of annotating the VNode at a suspend point (a component that threw during render) with _hydrateDom, annotate the VNode at the Suspense boundary (the component that implemented componentDidCatch()). When re-rendering a component, if its owner vnode has a boolean ._hydrating property value, that means we should attempt to resume from the VNode's current ._dom reference.
You can try this PR by checking out the suspense-hydration-testing branch of preactjs/cli-demo. Clone, then run npm i && npm link ../preact && npm run build && http-server -s -p 8080 build
Note: looking at this, I believe I need to change src/component.js L129 in order to enable resumption for trees that suspended during non-hydrate rendering:
vnode._hydrating != null ? [oldDom] : null
To-Do
- [ ] Fix test failures
- [ ] Add MutationObserver-based test from the cli-demo repo
- [ ] Test on
preact-www
Size Change: +28 B (0%)
Total Size: 38.4 kB
| Filename | Size | Change | |
|---|---|---|---|
dist/preact.js |
3.74 kB | +5 B (0%) | |
dist/preact.min.js |
3.74 kB | +5 B (0%) | |
dist/preact.module.js |
3.76 kB | +10 B (0%) | |
dist/preact.umd.js |
3.8 kB | +8 B (0%) |
ℹ️ View Unchanged
| Filename | Size | Change | |
|---|---|---|---|
compat/dist/compat.js |
2.95 kB | 0 B | |
compat/dist/compat.module.js |
2.97 kB | 0 B | |
compat/dist/compat.umd.js |
3 kB | 0 B | |
debug/dist/debug.js |
3.08 kB | 0 B | |
debug/dist/debug.module.js |
3.07 kB | 0 B | |
debug/dist/debug.umd.js |
3.14 kB | 0 B | |
devtools/dist/devtools.js |
175 B | 0 B | |
devtools/dist/devtools.module.js |
185 B | 0 B | |
devtools/dist/devtools.umd.js |
252 B | 0 B | |
hooks/dist/hooks.js |
1.06 kB | 0 B | |
hooks/dist/hooks.module.js |
1.08 kB | 0 B | |
hooks/dist/hooks.umd.js |
1.12 kB | 0 B | |
test-utils/dist/testUtils.js |
390 B | 0 B | |
test-utils/dist/testUtils.module.js |
392 B | 0 B | |
test-utils/dist/testUtils.umd.js |
469 B | 0 B |