I have a helper function connected(), this function is testing whether a user is online or not. It returns false if offline. I have this ant design modal and I am trying to call this function in the visible prop, in order to hide the modal if the user is not connected. I am not sure I am doing this right. Is it also necessary to put to have a useEffect ? Any idea on how to achieve this result
export const connected = async () => {
try {
const online = await fetch('/connection');
return online.status >= 200 && online.status < 300
} catch (err) {
return false
}
}
<Modal
title={test}
centered
visible={connected() ? isVisible : false}
closable={true}
onCancel={closeModal}
width={400}
>
<p>test</p>
</Modal>