Fix useEffect callback cannot be async

This commit is contained in:
Sofiya Tepikin
2022-09-20 15:32:47 +00:00
parent 8774d251de
commit d5f0e3532a
+15 -3
View File
@@ -31,9 +31,21 @@ const getSymptomsFromCycleDays = (cycleDays) =>
const CycleChart = ({ navigate, setDate }) => { const CycleChart = ({ navigate, setDate }) => {
const [shouldShowHint, setShouldShowHint] = useState(true) const [shouldShowHint, setShouldShowHint] = useState(true)
useEffect(async () => { useEffect(() => {
const flag = await getChartFlag() let isMounted = true
setShouldShowHint(flag === 'true')
async function checkShouldShowHint() {
const flag = await getChartFlag()
if (isMounted) {
setShouldShowHint(flag === 'true')
}
}
checkShouldShowHint()
return () => {
isMounted = false
}
}, []) }, [])
const hideHint = () => { const hideHint = () => {