mirror of
https://github.com/oceanprotocol/market.git
synced 2024-06-29 00:57:50 +02:00
487bcad8b4
* update * merge pr #1012 * fix header * fix * abort controller * up next.8 * build fix * update lock * fix * another fix * ssh fix * another ssh fix * remove optional
18 lines
437 B
TypeScript
18 lines
437 B
TypeScript
import { useRef, useEffect, useCallback } from 'react'
|
|
export const useAbortController = (): (() => AbortSignal) => {
|
|
const axiosSource = useRef(null)
|
|
const newAbortController = useCallback(() => {
|
|
axiosSource.current = new AbortController()
|
|
return axiosSource.current.signal
|
|
}, [])
|
|
|
|
useEffect(
|
|
() => () => {
|
|
if (axiosSource.current) axiosSource.current.abort()
|
|
},
|
|
[]
|
|
)
|
|
|
|
return newAbortController
|
|
}
|