Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of null (reading '__H') after Preact update #3393

Closed
maltium opened this issue Jan 4, 2022 · 8 comments
Closed

Comments

@maltium
Copy link

maltium commented Jan 4, 2022

We have a project that uses Preact that was mostly written when 10.0.0 was released. After updating to the latest Preact version, I'm getting a runtime error when mounting certain components.

image

After some digging I realized that this is happening upon mounting components that use hooks. Moreover, I performed a bisect on Preact version dependencies and found out that it starts to break from Preact 10.5.6 upwards (all other previous versions are fine).

To Reproduce

Unfortunately it's hard to isolate into a smaller project since the Preact part is only a small part of the whole project.

For now I've converted the affected components into class components and got things working again on the latest Preact.

@JoviDeCroock
Copy link
Member

Are you calling render from a different component by any chance 😅 tried to analyze your stacktrace but not getting that much wiser from it, it's also the only hooks-related change as of that release. The only other option is your bundler somehow duplicating code so the options calls aren't equal anymore.

We'll need a reproduction however if it's the former.

@maltium
Copy link
Author

maltium commented Jan 6, 2022

@JoviDeCroock it does seem to be the case of Preact being bundled twice, once for each library, but for some reason earlier versions didn't crash. So I'm closing this, thanks.

@jakeonfire
Copy link

also having this issue. looks like it’s trying to read at this line in the un-minified source: https://github.com/preactjs/preact/blob/10.10.3/hooks/src/index.js#L135
for whatever reason currentComponent isn’t set, which i think is supposed to happen in _render.

@JoviDeCroock what did you mean by:

The only other option is your bundler somehow duplicating code so the options calls aren't equal anymore.

what options calls?

@JoviDeCroock
Copy link
Member

Your bundler might be duplicating the preact bundle which would lead to currentComponent not being set as it would use the options from the preact that isn't used to render your DOM

@tombohub
Copy link

And what should we do to stop this double bundle?

@rschristian
Copy link
Member

@tombohub That depends entirely upon your tooling and environment.

@super-kamil
Copy link

in my case, i had to switch from class component to functional component to get rid of this error

@rschristian
Copy link
Member

You were probably misusing classes in some way, but would need a reproduction to offer any more guidance than that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants