]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/protocol/Protocol.js
properly abort requests
[alttp.git] / resources / js / components / protocol / Protocol.js
index 7cd0b754b1b19944d0e5b1124b3a3932187dd43b..a2bb93060a3fce351938b60588a392d2d63d0a25 100644 (file)
@@ -13,11 +13,15 @@ const Protocol = ({ id }) => {
        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(() => {