vendredi 5 avril 2019

React. Conditional Rendering

I have a React component:

class SignUpStepTwo extends Component {
constructor(props) {
        super(props);
        this.state = {
            isTherapistUpdated: false,
            isProfessionalInfoAdded: false,
            }
        }
     }
render() {
        if (!this.state.isTherapistUpdated) {
            return (
                <StepTwoPersonalInfo />
            );
        }
        else if (this.state.isTherapistUpdated) {
            return (
                <StepTwoProfessionalInfo/>
            );
        }
        else if (this.state.isProfessionalInfoAdded && 
                 this.state.isTherapistUpdated) {
            return (
                <StepTwoTermsOfUse/>
            );
        }
    }
}

export default SignUpStepTwo;

And I'm trying to change my bool flags and conditionnaly render my components. But the last if is never satisfied and the <StepTwoTermsOfUse/> component is not rendered.

Aucun commentaire:

Enregistrer un commentaire