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

Server side code fails with window undefined #104

Closed
uhef opened this issue Sep 11, 2017 · 3 comments
Closed

Server side code fails with window undefined #104

uhef opened this issue Sep 11, 2017 · 3 comments

Comments

@uhef
Copy link
Contributor

uhef commented Sep 11, 2017

When running form.io the server side fails with following:

/home/tuomjarv/workspace/emedi/kusote/node_modules/formiojs/build/formio.pdf.js:182
window.addEventListener('message', function (event) {
^

ReferenceError: window is not defined
    at Object.<anonymous> (.../node_modules/formiojs/build/formio.pdf.js:182:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (.../node_modules/formiojs/build/formio.full.js:11:16)
    at Module._compile (module.js:570:32)
@uhef
Copy link
Contributor Author

uhef commented Sep 11, 2017

This on react-formio@2.0.0

@eruby94
Copy link

eruby94 commented Jan 31, 2018

This means the component is tightly coupled to the DOM, and doesn't have its own checking for SSR usage. You may need to wrap it in a higher order component like NoSSR (https://github.com/kadirahq/react-no-ssr), or you could fork the code and modify it to only add the listener when the component is rendered in the browser.

@randallknutson
Copy link
Contributor

We're currently working on a version of formio.js that will have SSR support. The current version does not. See formio.js 4.x branch.

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

3 participants