lazy/Suspense causing re-rendering to break application
See original GitHub issuePerforming a re-render inside a lazy loaded component causes a TypeError
. This does not happen with React’s Suspense
.
The error can be reproduced with the current version of Preact. The problem does not exist in the 10.0.5 version.
It seems that the problem can be related with Suspense
not setting the children pointer correctly. This was addressed in the commit b0fe5e7, but with the change to version 10.1.X it was lost.
Reproduction
Codesandbox that reproduces the error in Preact: https://codesandbox.io/s/compassionate-bell-t0vww
Same codesandbox working in React: https://codesandbox.io/s/white-hooks-cdj8q
Steps to reproduce
Render an element inside a lazy loaded component and force a re-render.
In the sandbox there is a hook that calls setState
the first time the element is loaded.
Expected Behavior
The component should be re-rendered the first time setState
is called and then continue to work normally.
Actual Behavior
An error is thrown:
TypeError: Cannot set property ‘0’ of null
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top GitHub Comments
@marvinhagemeister thank u so much 🤝
@olabala We’ve just published
10.4.6
🎉