Cannot read property '__H' of undefined
faryar76 opened this issue · comments
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
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
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?
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"
temporary fix would be to disable esmExternals in next.config.js
experimental: {
esmExternals: false,
}
Wow thanks @quadrifolia this fixes it for me!!!
temporary fix would be to disable esmExternals in next.config.js
experimental: { esmExternals: false, }
Could you elaborate a bit on what this does? :)
+1 on what exactly this fix is doing
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.