Timing bug with Suspense render results in `TypeError: Cannot set property '0' of null.`
See original GitHub issueThe app crash I’m seeing originates from here and surfaced as TypeError: Cannot set property '0' of null.
This was discovered during an application reworking to use preact
rather than react
. The bug does not repro with react
.
Reproduction
CodeSandbox available here Minimal repo showing the issue is available here
Steps to reproduce
Force a re-render of a component hosting the <Suspense />
element before the initial fallback has rendered. In the minimal repro and my case, this was happening because something was being calculated and put into state during componentDidMount
.
Suspense
thinks it needs to render the fallback and detach the lazy
component, however, because of the external re-render, there are no children in the vnode
Expected Behavior
Either the lazy
is rerun, or the fallback is rendered.
Actual Behavior
The app crashes with TypeError: Cannot set property '0' of null.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:12 (1 by maintainers)
Top GitHub Comments
This shouldn’t be closed (or maybe a new issue should be made) because as of
10.5.14
, I get at.__H is null
error. When I downgrade to10.5.4
as per @imgalli suggests, it goes away.@rdalmas there were a couple of issues with suspense.
preact/compat
is causing one such bug. Fixed by wrapping only one lazy child inside a Suspense.preact-iso.lazy/hydrate
instead of regularlazy/hydrate