I am using antdesign, I am trying to open the modal whenever the connection is down. I used a useEffect and a local state just like for a regular modal but it does not seem to work
import React, { useState, useEffect } from 'react';
import 'antd/dist/antd.css';
import './index.css';
import { Modal } from 'antd';
const App = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
const online=Navigator.onLine
useEffect((online) => {
if (!online) {
setIsModalOpen(true);
}
}, [online]);
return (
<>
<Modal title="Basic Modal" open={isModalOpen} >
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
</>
);
};
export default App;