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

Cannot read property '__H' of undefined #61

Open
faryar76 opened this issue Jun 16, 2022 · 8 comments
Open

Cannot read property '__H' of undefined #61

faryar76 opened this issue Jun 16, 2022 · 8 comments

Comments

@faryar76
Copy link

faryar76 commented Jun 16, 2022

Hey :)

im testing preact with next.js and its ok. but when i tried to add some dependency(react-hook-form) and build
"Cannot read property '__H' of undefined" appears!

  • preactjs + react-hook-form ---> working wihtout any errors

  • next.js + preactjs + react-hook-form --->Cannot read property '__H' of undefined

packages are latest version

@sergeyzenchenko
Copy link

Hi having the same issue, this is caused by webpack in next js importing different module files from preact/compat
one from preact/compat/dist/compat.mjs.js and also from preact/compat/dist/compat.js

This plugin has some kind of "fix" for it, but looks like it's not working

@faryar76
Copy link
Author

faryar76 commented Jun 16, 2022

Hi having the same issue, this is caused by webpack in next js importing different module files from preact/compat one from preact/compat/dist/compat.mjs.js and also from preact/compat/dist/compat.js

This plugin has some kind of "fix" for it, but looks like it's not working

thank you for fast reply

what kind of fix ?
its builtin?
you have any solutions?

@Tobeyforce
Copy link

Tobeyforce commented Jun 25, 2022

Same, getting error mentioned above when using npm run build.
When using local dev server I'm also getting the "Error: Hook can only be invoked from render methods."

"next": "^12.1.6",
"next-plugin-preact": "^3.0.7",
"next-sitemap": "^3.0.4",
"next-themes": "^0.2.0",
"preact": "^10.8.2",
"preact-render-to-string": "^5.2.0",
"react": "npm:@preact/compat@^17.1.1",
"react-dom": "npm:@preact/compat@^17.1.1",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.2.0",
"sharp": "^0.30.3"

@quadrifolia
Copy link

temporary fix would be to disable esmExternals in next.config.js

experimental: {
esmExternals: false,
}

@kien-ngo
Copy link

Wow thanks @quadrifolia this fixes it for me!!!

@Tobeyforce
Copy link

temporary fix would be to disable esmExternals in next.config.js

experimental: { esmExternals: false, }

Could you elaborate a bit on what this does? :)

@bruceharrison1984
Copy link

+1 on what exactly this fix is doing

@Tobeyforce
Copy link

I'm not sure if this fix is the cause of my problem, but I've had massive memory leaks when building uusing esmExternals: false.

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