Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
immediate,
beforeRequest: myBeforeRequest,
afterRequest: myAfterRequest,
})
const retRef = useRef(ret)
useEffect(() => {
retRef.current = ret
}, [ret])
useMount(() => {
mounted.current = true
})
useUnmount(() => {
mounted.current = false
cancelNextPoll()
})
return ret
}
isLoading: false,
}))
cancelTokenSource.current = null
afterRequest && afterRequest()
}
useMount(() => {
mounted.current = true
if (immediate) {
sendRequest()
}
})
useUnmount(() => {
mounted.current = false
if (cancelTokenSource.current != null) {
cancelTokenSource.current.forEach((c) => c.cancel())
cancelTokenSource.current = null
}
})
return {
...state,
sendRequest,
}
}
}
}
cancelTokenSource.current = null
afterRequest && afterRequest()
}
useMount(() => {
mounted.current = true
if (immediate) {
sendRequest()
}
})
useUnmount(() => {
mounted.current = false
if (cancelTokenSource.current != null) {
cancelTokenSource.current.cancel()
cancelTokenSource.current = null
}
})
return {
...state,
sendRequest,
}
}