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(() => {
window.Echo.private(`Protocol.${id}`)
.listen('ProtocolAdded', e => {
- console.log(e);
if (e.protocol) {
setProtocol(protocol => [e.protocol, ...protocol]);
}