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 conditionally render my components.
But the last if is never satisfied and the <StepTwoTermsOfUse/> component is not rendered.
this.state.isTherapistUpdatedbeaandthis.state.isProfessionalInfoAddedbeb. So, it would read as If a does not exists, do this. If b exists, do that. But if a and b both exists, do something different. Now if bothaandbexists, 2nd condition automatically satisfies and it will not reach to 3rd condition. Try following style: If a exists and b also exists, do something else. But if b doesn't exists, do that. And finally if a doesn't exists, do this