# @alicloud/xconsole-query

> > Query 组件提供获取数据的能力

Latest version **2.3.21** (published 2021-06-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @alicloud/xconsole-query
pnpm add @alicloud/xconsole-query
yarn add @alicloud/xconsole-query
bun add @alicloud/xconsole-query
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.21 |
| Published | 2021-06-17 |
| First published | 2020-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 88 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 82 |
| Maintainers | jacksontian, fengmk2, pagecao, aliyunsdkteam, console-fe |

## Links

- npm: https://www.npmjs.com/package/@alicloud/xconsole-query
- Repository: https://github.com/aliyun/alibabacloud-console-design
- Issues: https://github.com/aliyun/alibabacloud-console-design/issues
- npm.io page: https://npm.io/package/@alicloud/xconsole-query

## Dependencies (5)

- [@types/react](https://npm.io/package/@types/react.md) ^16.8.24
- [lodash.isequal](https://npm.io/package/lodash.isequal.md) ^4.5.0
- [lodash.isfunction](https://npm.io/package/lodash.isfunction.md) ^3.0.9
- [@types/webpack-env](https://npm.io/package/@types/webpack-env.md) ^1.14.0
- [@alicloud/xconsole-model](https://npm.io/package/@alicloud/xconsole-model.md) ^2.3.21

## Recent versions

- 2.3.21 (latest) — 2021-06-17
- 2.0.0-next.2 (next) — 2020-09-29
- 2.0.0-alpha.7 (alpha) — 2020-08-13
- 2.3.4 — 2021-03-04
- 2.2.4 — 2020-11-17
- 2.2.3 — 2020-11-17
- 2.0.1 — 2020-10-16
- 1.0.0-beta.3 — 2020-10-16
- 2.0.0-next.1 — 2020-09-29
- 2.0.0-alpha.6 — 2020-08-12
- 2.0.0-alpha.5 — 2020-08-05
- 2.0.0-alpha.4 — 2020-08-05
- 2.0.0-alpha.3 — 2020-08-04
- 2.0.0-alpha.2 — 2020-08-04
- 2.0.0-alpha.1 — 2020-08-04
- … 2 more at https://npm.io/package/@alicloud/xconsole-query/versions

## README

# @alicloud/xconsole-query

> Query 组件提供获取数据的能力

## APIs

### Query

|Param|Type|Default|Description|
|-----|----|-------|-----------|
|query|`XConsoleModel`||封装后的 model 对象|
|variables|`object`||请求参数|
|onCompleted|`function`||请求完成回调|
|onError|`function`||请求错误回调|

## Usage

```js
import { Query } from '@alicloud/xconsole'

const App = () => (
  <Query
    query={GetInstancesModel}
    variables={{ regionId: 'cn-hangzhou' }}
    onCompleted={(data) => {}}
    onError={(error) => {}}
  >
      {
        ({ data, loading, error, refetch, variables }) => (
          //...
        )
      }
  </Query>
);
```
### refetch(newVars: object, useOldVars: boolean) 支持传入两个参数：

`newVars` 这部分参数和会从 Query props 传入的 `variables` 合并后保存在组件内部，直到 Query props 的 variables 发生改变，所以搜索和翻页功能也可以通过 refetch 实现。

`useNewVars` 默认值为false；当为 true 时，表示不与从 Query props 传入的 `variables` 合并, 而直接使用 newVars 参数；

---
_Source: https://npm.io/package/@alicloud/xconsole-query · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
