-
Notifications
You must be signed in to change notification settings - Fork 30
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
ReferenceError: document is not defined. Server Side rendering does not seem to work. #6
Comments
Ah yeah that's a good point. This uses the browser's built-in DOM parser, which isn't available under node. Should be possible to detect node and require() in a simple parser lib though! Will need to update the code :) |
Preact WMR injects a NodeJS globalThis.DOMParser = new (require('jsdom').JSDOM)('').window.DOMParser; (PR context: https://github.com/preactjs/wmr/pull/497/files ) This way, this never fails: preact-markup/src/parse-markup.js Lines 22 to 26 in 4788b8d
...and this preact-markup/src/parse-markup.js Lines 60 to 69 in 4788b8d
Related PRs: |
Hi
I am trying to use the Markup component while rendering server side with preact-render-to-string.
I get the following error: 'ReferenceError: document is not defined'
Could you suggest a work around?
The text was updated successfully, but these errors were encountered: