mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 11:24:13 -05: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
|
|
}
|