preact-cli
preact-cli copied to clipboard
Null check missing in AsyncComponent.getPreviousSibling()
- [ ] Check if updating to the latest Preact version resolves the issue
Describe the bug Uncaught TypeError: Cannot read properties of null (reading 'type') at getPreviousSibling (async.js?7a7b:8:1) at getPreviousSibling (async.js?7a7b:19:1) at getPreviousSibling (async.js?7a7b:23:1) at getPreviousSibling (async.js?7a7b:23:1) at AsyncComponent.render (async.js?7a7b:48:1)
To Reproduce Unfortunately, this is part of a large app and it is not easy to isolate a sample. Luckily, this is a simple null-check error with an easy fix.
Replace if (typeof vnode.type === 'string') return null;
With if (!vnode || typeof vnode.type === 'string') return null;
Since a recursive call is sending a null vnode.
Expected behavior Page should re-render on a setState but the above error occurs.
That doesn't seem to be part of our codebase 😅
EDIT: ah I found it, this needs to go to to the Preact CLI repo https://github.com/preactjs/preact-cli/blob/master/packages/async-loader/async.js#L6
Thanks! Want to write up a PR fixing this?
Reminded me of #1424 which looks to be the same issue.