Skip to content

Changing the state of the survey not working/ new questions not appearing #17

@sanchocreativo

Description

@sanchocreativo

Based on answer submitted, I tryed to concat the previous state of the survey with a new array of questions and the new questions are not appearing.

State:

  constructor(props) {
        super(props);
        this.state = { 
            backgroundColor: PURPLE, 
            answersSoFar: '', 
            countryState: '',
            survey: [
                {
                    questionType: 'SelectionGroup',
                    questionText:
                        '¿Como te encuentras de estado de salud? ',
                    questionId: 'radiopais',
                    questionSettings: {
                        allowDeselect: false,
                    },
                    options: [
                        {
                            optionText: 'Bien 💚',
                            value: 'si'
                        },
                        {
                            optionText: 'Mal 🔴',
                            value: 'no'
                        },
                       
                    ]
                },

...continues...

  onAnswerSubmitted(answer) {
        this.setState({ answersSoFar: this.surveyRef.getAnswers() });
        switch (answer.questionId) {
            case 'radiopais': {
                if (answer.value == 'si') {
                    this.setState({ 
                        survey: [...this.state.survey, ...countryQe]
                    });               
                }
                break;
            }
            default:
                break;
        }

    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions