-
-
Notifications
You must be signed in to change notification settings - Fork 372
Closed
Labels
Description
Ported over from: preactjs/preact-render-to-string#86 (comment)
Do you want to request a feature or report a bug?
bug
What is the current behaviour?
Prerendering will throw an undefined error:
TypeError: Cannot read property '__H' of undefinedThis is caused by loading multiple instances of preact which can't see each others option-hooks. There are a total of 2 instances at play:
- included in the generated
ssr-bundle.js - one inside
prerender.js: https://github.com/developit/preact-cli/blob/bd464043dac8646183ed9a8cfab677778f73b4f7/packages/cli/lib/lib/webpack/prerender.js#L28
Both instances have their own options variable which ultimately leads to this error.
If the current behaviour is a bug, please provide the steps to reproduce.
{
"scripts": {
"build": "preact build"
},
"devDependencies": {
"preact-cli": "^3.0.0-rc.1",
"preact-render-to-string": "^5.0.3"
},
"dependencies": {
"preact": "^10.0.0-beta.1"
}
}import { useState } from "preact/hooks";
export default () => {
const [a, b] = useState("c");
return <h1>Hello, World! {a}</h1>;
};What is the expected behaviour?
It should not throw.
Please mention other relevant information.
- Node version: 11.7
- npm version 6.5.0
- Operating system: Linux Debian Sid
- CLI version: 3.0.0-rc.1
- Browser: doesn't matter