Heredé un proyecto de reacción y no puedo descifrar cómo usar el módulo survey-react . Sigo recibiendo este error en http://localhost:3000/
Uncaught TypeError: this.addEvent is not a function node_modules/survey-react/survey.react.js:2582 2579 | * options.newValue - new value. 2580 | */ 2581 | > 2582 | this.onPropertyChanged = this.addEvent(); | ^ 2583 | /** 2584 | * Event that raised on changing property of the ItemValue object. 2585 | * sender - the object that owns the propertySimplifiqué mi proyecto a solo 3 archivos, que son:
Este es mi src/index.js .
import React from 'react'; import ReactDOM from 'react-dom'; import * as Survey from 'survey-react'; const questions = { elements:[{"type":"comment","name":"If you could enhance one thing about this product, what would it be?","isRequired":true}] }; const srv = Survey.Model(questions); srv.data = {"If you could enhance one thing about this product, what would it be?":"I like it as is, no changes needed."}; ReactDOM.render(<Survey.Survey model={srv} />, document.getElementById('root')); Este es mi package.json
{ "name": "testingthis", "version": "0.1.0", "private": true, "dependencies": { "babel-jest": "^23.6.0", "react": "^16.6.1", "react-dom": "^16.4.2", "react-scripts": "^2.1.8", "survey-react": "1.9.33" }, "scripts": { "start": "react-scripts start" }, "eslintConfig": { "extends": "react-app" }, "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ] } Este es mi public/index.html
<!DOCTYPE html> <html lang="en"> <body> <div id="root"></div> </body> </html¿Qué estoy haciendo mal?
No puedo encontrar ninguna documentación sobre el paquete Survey-React, pero los documentos oficiales en el sitio de SurveyJS dicen que debe usar los paquetes Survey -Core y Survey-React - UI ( https://surveyjs.io/Documentation/Library? id=comenzar-reaccionar ):
import { StylesManager, Model } from "survey-core"; import { Survey } from "survey-react-ui";Entonces, cambie a esos, o si insiste en usar encuesta-reaccionar , puede hacer que funcione cambiando su código de esta manera:
import React from "react"; import ReactDOM from "react-dom"; import * as Survey from "survey-react"; const questions = { elements: [ { type: "comment", name: "If you could enhance one thing about this product, what would it be?", isRequired: true } ] }; const data = { "If you could enhance one thing about this product, what would it be?": "I like it as is, no changes needed." } ReactDOM.render(<Survey.Survey json={questions} data={data} />, document.getElementById("root"));