there is a food function with props that is type which is equal to 'Lunch' or 'Dinner' I need to change the value of LunchStatus when submit is clicked according to the condition on type
const Food = (props) =>{
const [LunchStatus, LunchUpdate] = useState('Lunch YES');
const [DinnerStatus, DinnerUpdate] = useState('Dinner YES');
function handlingSubmit(e){
if(props.type === 'Lunch'){
LunchUpdate('Lunch NO');
console.log(LunchStatus);
}
else{
DinnerUpdate('Dinner NO');
console.log(DinnerStatus);
}
}
return (
<div className='food-box'>
<button class="button_raise" onClick={handlingSubmit}>Submit</button>
</div>
);
}
and output is showing Lunch YES and Dinner YES for first clicks and Lunch NO and Dinner NO for remaining clicks
the output is like when I click both one after one continuously is
Lunch YES
Dinner YES
Lunch NO
Dinner NO
Lunch NO
Dinner NO