mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-23 16:52:53 +00:00
d959dbc236
[web] Shared React hooks JS to TS conversion GitOrigin-RevId: 0ccdebff236c7424b1a73cd7d6646a9d01a20eb1
14 lines
301 B
TypeScript
14 lines
301 B
TypeScript
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
|
|
}
|