i'm working on a MERN project and it's been weeks that i have an issue with React states. I use a state to display a Popup or not.
That's the way i'm displaying it:
{OptionsPopUpState
? <OptionsPopUp func={OptionsPopUpfunc} name={OptionsPopUpData.name} id={OptionsPopUpData.id} shared={OptionsPopUpData.shared} languageQuestion={OptionsPopUpData.languageQuestion} languageAnswer={OptionsPopUpData.languageAnswer} />
: ""
}
The function passed in props is the one which hide or display it depending on the state.
Here's the function:
if(OptionsPopUpState){
SetOptionsPopUpState(false)
console.log("New state "+OptionsPopUpState)
refresh(); //refresh when close the popup
}
else{
console.log("display")
SetOptionsPopUpState(true);
}
I don't get why it is not working because i use exactly the same code for an other popup and it works perfectly. On the top of it, when i print the state just after having changed it, no change...
Does anyone understand the problem's origin ? Thanks
Via Active questions tagged javascript - Stack Overflow https://ift.tt/CcWDh6N
Comments
Post a Comment