surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.21k stars 815 forks source link

Document is not defined #1375

Closed shwetakilledar closed 4 years ago

shwetakilledar commented 6 years ago

Are you requesting a feature, reporting a bug or asking a question?

Bug/Issue

What is the current behavior?

I am using react-starter-kit. Getting document is not defined error on webpage

What is the expected behavior?

Webpage should render the Quiz component

Provide the test code and the tested page URL (if applicable)

Tested page URL:

your_code_here

import React from 'react';
import * as Survey from 'survey-react';
import 'survey-react/survey.css';
import 'bootstrap/dist/css/bootstrap.css';

class Quiz extends React.Component {
  componentWillMount() {
      Survey.Survey.cssType = "bootstrap";
    }

  json = {
    showProgressBar: "top",
    pages: [
     {
      name: "1st Quarter",
      elements: [
       {
        type: "radiogroup",
        name:  "Question1",
        title:  "Question 1?",
        choices: ["yes","no"],
        isRequired: true
       },
       .
       .
       .
      ],
       .
       .
      .
      title: "3rd Quarter",
      navigationButtonsVisibility: "show"
     }
    ],
     sendResultOnPageNext: true
    };

  render(){
  var model = new Survey.Model(this.json);
    return (
      <div>
         <Survey.Survey model={model} onComplete={this.onComplete.bind(this)} />
      </div>
    );
  }
}

### Specify your

* browser: chrome
* browser version: 69.0.3497.100
* surveyjs platform (angular or react or jquery or knockout or vue): react
* surveyjs version: 1.0.29

**** Error Log ***

 ReferenceError: document is not defined

  - stylesmanager.ts:351 Function.StylesManager.findSheet
    [App]/[survey-react]/webpack:/src/stylesmanager.ts:351:25

  - stylesmanager.ts:411 new StylesManager
    [App]/[survey-react]/webpack:/src/stylesmanager.ts:411:32

  - survey.ts:43
    [App]/[survey-react]/webpack:/src/survey.ts:43:34

  - survey.ts:3139 Object.<anonymous>
    [App]/[survey-react]/webpack:/src/survey.ts:3139:2

  - bootstrap 8931ae580ff98c6c8e65:19 __webpack_require__
    [App]/[survey-react]/webpack:/webpack/bootstrap 8931ae580ff98c6c8e65:19:1

  - survey.react.js:16774 Object.<anonymous>
    [App]/[survey-react]/survey.react.js:16774:67

  - bootstrap 8931ae580ff98c6c8e65:19 __webpack_require__
    [App]/[survey-react]/webpack:/webpack/bootstrap 8931ae580ff98c6c8e65:19:1

  - survey.react.js:25655 Object.<anonymous>
    [App]/[survey-react]/survey.react.js:25655:72

  - bootstrap 8931ae580ff98c6c8e65:19 __webpack_require__
    [App]/[survey-react]/webpack:/webpack/bootstrap 8931ae580ff98c6c8e65:19:1

  - bootstrap 8931ae580ff98c6c8e65:65 __webpack_exports__.b
    [App]/[survey-react]/webpack:/webpack/bootstrap 8931ae580ff98c6c8e65:65:1

  - survey.react.js:84
    [App]/[survey-react]/survey.react.js:84:10

  - universalModuleDefinition:3 webpackUniversalModuleDefinition
    [App]/[survey-react]/webpack:/webpack/universalModuleDefinition:3:1

  - universalModuleDefinition:10 Object.<anonymous>
    [App]/[survey-react]/webpack:/webpack/universalModuleDefinition:10:2

  - index.js:83 Module._compile
    [App]/[pirates]/lib/index.js:83:24

  - index.js:88 Object.newLoader [as .js]
    [App]/[pirates]/lib/index.js:88:7

  - module.js:11 require
    internal/module.js:11:18

  TypeError: action.default is not a function

  - router.js:16 context.route.load.then.action
    App/src/router.js:16:1

  TypeError: action.default is not a function

  - router.js:16 context.route.load.then.action
    App/src/router.js:16:1
dmitry-kurmanov commented 6 years ago

@shwetakilledar thank you for the report.

react-starter-kit - isomorphic web app boilerplate. I think that the problem relates to nodejs environment. There is no document there.

We will try to init react-starter-kit and reproduce the problem.

tsv2013 commented 6 years ago

@shwetakilledar Do I understand you right that you are using server-side rendering? Unfortunately SurveyJS at this moment doesn't support server-side rendering.

AnnemiekeNL commented 5 years ago

@tsv2013 Is support for server-side rendering on the roadmap? I would really like to use survey.js with nuxt.

tsv2013 commented 4 years ago

@AnnemiekeNL So sorry for this very late response. No we don't have such plans for a while.