【发布时间】:2021-10-27 02:17:19
【问题描述】:
我已收到 boolean 值并设置为 setNomStatus,但如何检查是否为 true 以显示 setShowCalender(true)?
const [nomStatus, setNomStatus] = useState(false);
useEffect(() => {
const fetchData = async () => {
const email = localStorage.getItem("loginEmail");
try {
const res = await Axios.get(
"http://localhost:8000/service/activeStatus", {email}
);
setNomStatus(res.data[0].status);
console.log("Get status data :" + res.data[0].status);
if(nomStatus == true){
setShowCalender(true);
}
} catch (e) {
console.log(e);
}
};
fetchData();
}, []);
【问题讨论】:
标签: reactjs react-hooks use-effect use-state