Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sanchocreativo opened this issue Mar 18, 2020 · 1 comment

Comments

@sanchocreativo
Copy link

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;
        }

    }

@sanchocreativo
Copy link
Author

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

}

I am sorry it was my mistake. It was if(answer.value.value). However when last question is set it doesnt send an onAnswerSubmitted so the new question is not rendered. So the issue remains opened regardless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant