Reputation: 105
handleClick=()=>{
console.log("final course values"+ " "+this.state.selectCourseValue)
console.log("selected teacher"+ " "+this.state.selectedTeacher)
if(this.state.selectCourseValue ===null && this.state.selectedTeacher !== undefined)
{
console.log("please select")
message.warning('Add course')
return;
}
else{
console.log("Sucessfully updated")
}
}
Upvotes: 0
Views: 45
Reputation: 130132
If selectCourseValue
is an array, then your condition should be probably this:
if (this.state.selectedTeacher && (this.state.selectCourseValue || []).length === 0) {
}
Checking that selectedTeacher
is not empty and selectCourseValue
is empty.
Upvotes: 1