overleaf/services/web/frontend/js/shared/hooks/use-abort-controller.ts

15 lines
301 B
TypeScript
Raw Normal View History

import 'abort-controller/polyfill'
import { useEffect, useState } from 'react'
export default function useAbortController() {
const [controller] = useState(() => new AbortController())
useEffect(() => {
return () => {
controller.abort()
}
}, [controller])
return controller
}