Preact: Cryptic error when using preact/compat

Created on 2 Oct 2019  路  8Comments  路  Source: preactjs/preact

I just tried to use preact/compat on my quite complex project. It was using Preact 8.x before, but when hooks came out we decided to temporarily move back to React. I basically just installed the new preact version and aliased it through webpack and then ran my app again. It partially renders and I'm afraid this might have something to do with the partial support for <Suspense />, but I'm getting this cryptic error:

Uncaught (in promise) TypeError: Cannot read property '__c' of null
    at Object.MOxe.preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount (hooks.module.js:1)
    at D (preact.module.js:1)
    at r (compat.module.js:1)

For some reason source mapping also doesn't work for me with preact/compat which makes it very hard to debug this by myself.

2-phase-commit

All 8 comments

Hmm. The stack trace seems to be coming from hooks:
https://github.com/preactjs/preact/blob/4aa291e2af18e53f8106d60a5ab1402d903d5421/hooks/src/index.js#L43

Somehere the unmount hook is getting called with null instead of a valid VNode object. My guess is that it's this call to unmount(), which would generate the null case if you're using <Suspense> without the fallback= prop.

Are you using <Suspense> without fallback?

Nm

I was using <Suspense fallback={null} /> which is valid in React and apparently breaks in Preact X. Changing it to <Suspense fallback={<span />} /> fixed it.

@developit is that something we want to change?

@PepijnSenders The Suspense API and preliminary support is there in X, but it's not yet recommended for widespread use. It's basically a very early alpha preview and because of that it has many known bugs.

Properly supporting Suspense requires refactoring our renderer architecture a bit, which is doable, but will take time. We didn't ship that with the initial X release, because it would have delayed it way too much.

Understood, it was already quite late so good that you brought it out anyways!

Supporting a null fallback should be pretty simple. We render Text nodes for null roots.

I believe #2030 should fix this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasongerbes picture jasongerbes  路  3Comments

mizchi picture mizchi  路  3Comments

kay-is picture kay-is  路  3Comments

youngwind picture youngwind  路  3Comments

adriaanwm picture adriaanwm  路  3Comments