# @connect-xyz/withdraw-react 中文文档

规范地址：https://npmcn.com/package/%40connect-xyz/withdraw-react/

版本：0\.54\.13
npm 元数据更新时间：2026-11-04T14:37:06.947Z
中文译文更新时间：2026-11-14T07:49:51.393Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40connect-xyz/withdraw-react
原文对照：https://npmcn.com/package/%40connect-xyz/withdraw-react/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：24.8 kB，4 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \>=18\.0\.0，react-dom \>=18\.0\.0
- 首次发布：2025-12-23T12:25:19.014Z
- 最新版本发布：2026-11-04T14:37:06.733Z
- 近 30 天下载量：2122（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：92（近 12 个月 92 个）

## 中文简介

一个能使前端反应应用程序能与Connect Reaction产品无缝地相接的SDK.

## 安装

```sh
npm install @connect-xyz/withdraw-react
```

也可以使用：`pnpm add @connect-xyz/withdraw-react`、`yarn add @connect-xyz/withdraw-react`、`bun add @connect-xyz/withdraw-react`

## README

# @ 连接- xyz/ 退出- react

一个能使前端反应应用程序能与Connect Reaction产品无缝地相接的SDK.

连接退出为终端用户提取资金提供了一个安全的途径. 学多一点 [连接撤回文档](https://docs.zerohash.com/docs/withdraw)。 。 。 .

## 所需资源

-   反应18.0.0或以上
-   反应DOM 18.0.0或以上

## 安装

```bash
npm install @connect-xyz/withdraw-react
```

## 开始

遵循这些简单的步骤, 将退出整合到您的 React 应用程序中 :

### 1\. 进口撤回部分

```tsx
import { Withdraw } from '@connect-xyz/withdraw-react';
```

### 2\. 在您的应用程序中添加撤回组件

```tsx
function App() {
  const jwt = 'your-jwt-token'; // Obtain this from your backend authentication

  return (
    <Withdraw
      jwt={jwt}
      env="production" // or "sandbox" for testing
    />
  );
}
```

### 3\. 配置事件召回(可选)

听从撤销 SDK 的事件处理用户交互 :

```tsx
function App() {
  const jwt = 'your-jwt-token';

  const handleError = ({ errorCode, reason }) => {
    console.log('Withdraw error occurred:', errorCode, 'Reason:', reason);
  };

  const handleClose = () => {
    console.log('Withdraw widget closed');
  };

  const handleWithdrawal = ({ data }) => {
    console.log('Withdrawal data:', data);
  };

  const handleEvent = ({ type, data }) => {
    console.log('Withdraw event:', type, 'Data:', data);
  };

  const handleLoaded = () => {
    console.log('Withdraw widget loaded and ready');
  };

  return (
    <Withdraw
      jwt={jwt}
      env="production"
      onError={handleError}
      onClose={handleClose}
      onWithdrawal={handleWithdrawal}
      onEvent={handleEvent}
      onLoaded={handleLoaded}
    />
  );
}
```

关于召回事件及其有效载荷的详情,见 [连接 SDKs 调用文档](https://docs.zerohash.com/docs/front-end-callbacks)。 。 。 .

## 完整示例

以下是将 Connect request 整合到您的 React 应用程序的完整实例 :

```tsx
import { Withdraw } from '@connect-xyz/withdraw-react';
import React from 'react';

function App() {
  // JWT token should be obtained from your backend
  const jwt = 'your-jwt-token';

  // Choose environment: "production" for live apps, "sandbox" for testing
  const environment = 'production';

  return (
    <div className="App">
      <h1>My Crypto App</h1>

      <Withdraw
        jwt={jwt}
        env={environment}
        onError={({ errorCode, reason }) => {
          console.log('Error:', errorCode, 'Reason:', reason);
        }}
        onClose={() => {
          console.log('Withdraw widget closed');
        }}
        onWithdrawal={({ data }) => {
          console.log('Withdrawal successful:', data);
        }}
        onEvent={({ type, data }) => {
          console.log('Event type:', type, 'Event data:', data);
        }}
        onLoaded={() => {
          console.log('Withdraw widget loaded and ready');
        }}
      />
    </div>
  );
}

export default App;
```

## API 参考

### 撤销组件道具

| Prop | 类型 | 需求 | 默认 | 说明 |
| --- | --- | --- | --- | --- |
| `jwt` | `string` | 对 | \- 说吧 | 用 Connect 撤回认证的 JWT 令牌 |
| `env` | `"production" | "sandbox"` | 没有 | `"production"` | 目标环境 |
| `theme` | `"auto" | "light" | "dark"` | 没有 | `"auto"` | 界面的主题模式 |
| `onError` | `({ errorCode, reason }) => void` | 没有 | \- 说吧 | 调用错误事件 |
| `onClose` | `() => void` | 没有 | \- 说吧 | 部件关闭时召回 |
| `onWithdrawal` | `({ data }) => void` | 没有 | \- 说吧 | 撤回请求完成 |
| `onEvent` | `({ type, data }) => void` | 没有 | \- 说吧 | 召回一般活动 |
| `onLoaded` | `() => void` | 没有 | \- 说吧 | 部件装入并准备就绪时召回 |

## 更多信息与支持

关于Connect撤回的全面文件或支持,请访问 [页 次](https://docs.zerohash.com/docs/withdraw)。 。 。 .

## 常见问题

### @connect-xyz/withdraw-react 是什么？

一个能使前端反应应用程序能与Connect Reaction产品无缝地相接的SDK\.

### 如何安装 @connect-xyz/withdraw-react？

在项目目录运行 npm install @connect-xyz/withdraw-react，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\>=18\.0\.0）、react-dom（\>=18\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @connect-xyz/withdraw-react 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @connect-xyz/withdraw-react 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @connect-xyz/withdraw-react 可以商用吗？

@connect-xyz/withdraw-react 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @connect-xyz/withdraw-react 的下载量有多少？

根据 npm 官方下载统计，@connect-xyz/withdraw-react 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,122 次，日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @connect-xyz/withdraw-react 还在维护吗？

最新版本 0\.54\.13 发布于 2026/11/04（9 天前）；至今共发布 92 个版本，其中过去 12 个月发布了 92 个；首次发布于 2025/12/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

