1

Are there any code samples that show how to use Surveyjs with React and TypeScript? I tried importing it into my project and using the sample code from here.

https://stackblitz.com/edit/surveyjs-react-stackoverflow45544026

I got a module parse error on this line.

import "survey-react/survey.css";

So, I tried commenting it out to see what would happen. Then, TypeScript complained about this line

var model = new Survey.Model(json);  

It said Model does not exist.

My project contains the type definitions in survey.react.d.ts. So, I'm not sure what the issue is.

Thanks,

Mike

Mikutus
  • 83
  • 1
  • 10

1 Answers1

2

I use Surveyjs in Angular which uses TypeScript.

I generally do : import * as Survey from "survey-angular"; and we dont any errors like Model does not exist etc.

I would suggest you to try out: import * as Survey from "survey-react"; and check if its working.

Also, if you want quick start boilerplate of React+Surveyjs , you clone/fork from this link

Akhil
  • 1,403
  • 7
  • 19