mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
15 lines
301 B
JavaScript
15 lines
301 B
JavaScript
|
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
|
||
|
}
|