Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
} catch (e) {
if (mounted.current) {
setState({
error: e,
isLoading: false,
})
}
}
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,
afterRequest?.()
}
const ret = useClientRequest(reqFactory, {
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
}
error: reqFactories.map((_) => null),
}))
const p = reqFactories.map((_, idx) => sendRequestEach(idx))
await Promise.all(p)
setState((s) => ({
...s,
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,
export default function SearchHeader({ taskGroupID }: Props) {
const { t } = useTranslation()
const navigate = useNavigate()
const [form] = Form.useForm()
const [isSubmitting, setSubmitting] = useState(false)
const instanceSelect = useRef(null)
useMount(() => {
async function fetchData() {
if (!taskGroupID) {
return
}
const res = await client
.getInstance()
.logsTaskgroupsIdGet(String(taskGroupID))
const { task_group, tasks } = res.data
const { start_time, end_time, min_level, patterns } =
task_group?.search_request ?? {}
const fieldsValue: IFormProps = {
timeRange: {
type: 'absolute',
value: [start_time! / 1000, end_time! / 1000],
},
logLevel: min_level || 2,