const [protocol, setProtocol] = useState([]);
useEffect(() => {
+ const ctrl = new AbortController();
axios
- .get(`/api/protocol/${id}`)
+ .get(`/api/protocol/${id}`, { signal: ctrl.signal })
.then(response => {
setProtocol(response.data);
});
+ return () => {
+ ctrl.abort();
+ };
}, [id]);
useEffect(() => {