How to use the @umijs/hooks.useUnmount function in @umijs/hooks

To help you get started, we’ve selected a few @umijs/hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pingcap / tidb-dashboard / ui / lib / utils / useClientRequest.ts View on Github external
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
}
github pingcap / tidb-dashboard / ui / lib / utils / useClientRequest.ts View on Github external
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,
  }
}
github pingcap / tidb-dashboard / ui / lib / utils / useClientRequest.ts View on Github external
}
    }

    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,
  }
}