Question T5971
Visible to All Users

custom widget show blank in survey creator (Survey Designer ,Test)

created 4 years ago (modified 4 years ago)

Hi Team,
I have build one custom component(CameraStream) in react which work fine when run individually. When i am adding same jsx component(CameraStream) as widget(check code in attachment) in survey creator which add successfully, But when it render then render as a black question.

NOTE: afterRender is not call when i set htmlTemplate: <CameraStream Text='Yourself' />, afterRender is call when i set htmlTemplate: "<CameraStream Text='Yourself' />"

For reference i am attaching below files

  1. CameraStream component (this work individually).
  2. camerastreamwidget.js which is a custom widget.
  3. SurveyCreator.js
  4. screenshots of error
Show previous comments (5)

    Hello Serge T,
    Camera code has been written into separate file called CameraStream(refer attachment CameraStream.txt) component, which pass as htmlTemplate: <CameraStream Text='Yourself' />.

    So, Kindly suggest how to pass react component which already working individually, but i want to pass that component to as a surveyjs control.

      Hello,

      Custom widgets are framework-indepoendent. In order to render a react component inside you need to use the "ReactDOM.render" function or write a custom widget in a vanilla JavaScript.
      If you want to use a react component as a custom question type, you can check the https://github.com/surveyjs/surveyjs_react_quickstart/blob/master/src/MyQuestion.js file.

      Thanks, Serge
      SurveyJS Team

        Hello,

        Important note.
        At this moment SurveyJS Creator works over the survey-knockout library. That's why if you want to widget to be available in creator you need to implement it in framework-agnostic way.

        Thanks, Serge
        SurveyJS Team