Skip to content

Commit

Permalink
chore: upgrade to ahooks & delete unused hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
brickspert committed Apr 21, 2020
1 parent fcf5e49 commit 4ff6fd8
Show file tree
Hide file tree
Showing 156 changed files with 197 additions and 5,314 deletions.
10 changes: 5 additions & 5 deletions .umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
},
]],
mode: 'site',
title: 'Umi Hooks',
title: 'ahooks',
dynamicImport: {},
manifest: {},
links: [{ rel: "manifest", href: "/asset-manifest.json" }],
Expand All @@ -22,13 +22,13 @@ export default {
navs: {
'zh-CN': [
null,
{ title: 'GitHub', path: 'https://github.com/umijs/hooks' },
{ title: '更新日志', path: 'https://github.com/umijs/hooks/releases' },
{ title: 'GitHub', path: 'https://github.com/ice-lab/ahooks' },
{ title: '更新日志', path: 'https://github.com/ice-lab/ahooks/releases' },
],
'en-US': [
null,
{ title: 'GitHub', path: 'https://github.com/umijs/hooks' },
{ title: 'Changelog', path: 'https://github.com/umijs/hooks/releases' },
{ title: 'GitHub', path: 'https://github.com/ice-lab/ahooks' },
{ title: 'Changelog', path: 'https://github.com/ice-lab/ahooks/releases' },
],
},
headScripts: [
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

> 参考 ant design [贡献指南](https://ant.design/docs/react/contributing-cn)
这篇指南会指导你如何为 `@umijs/hooks` 贡献一份自己的力量,请在你要提 issue 或者 pull request 之前花几分钟来阅读一遍这篇指南。
这篇指南会指导你如何为 `ahooks` 贡献一份自己的力量,请在你要提 issue 或者 pull request 之前花几分钟来阅读一遍这篇指南。

## 透明的开发

我们所有的工作都会放在 [GitHub](https://github.com/umijs/hooks) 上。不管是核心团队的成员还是外部贡献者的 pull request 都需要经过同样流程的 review。
我们所有的工作都会放在 [GitHub](https://github.com/ice-lab/ahooks) 上。不管是核心团队的成员还是外部贡献者的 pull request 都需要经过同样流程的 review。

## 分支管理

Expand Down Expand Up @@ -35,7 +35,7 @@

在你 clone 代码并且使用 `npm run init` 安装完依赖后,你还可以运行下面几个常用的命令:

1. `npm start` 在本地运行 `@umijs/hooks` 网站。
1. `npm start` 在本地运行 `ahooks` 网站。

2. `npm run test` 运行测试。

Expand Down
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
English | [简体中文](https://github.com/umijs/hooks/blob/master/README.zh-CN.md)
English | [简体中文](https://github.com/ice-lab/ahooks/blob/master/README.zh-CN.md)

# @umijs/hooks
# ahooks

React Hooks Library.

Expand All @@ -18,27 +18,22 @@ React Hooks Library.
* Contains a wealth of basic Hooks.
* Written in TypeScript with predictable static types.

## 📣 Explain

**You can use umi hooks anywhere, with any component library.**
Although our examples are based on ant design, it does not mean that our Hooks can only be used with ant design.

## 📦 Install

```
npm i @umijs/hooks --save
npm i ahooks --save
```

## 🔨 Usage

```
import { useRequest } from '@umijs/hooks';
import { useRequest } from 'ahooks';
```

## 🖥 Development

```
$ git clone git@github.com:umijs/hooks.git
$ git clone git@github.com:ice-lab/ahooks.git
$ cd hooks
$ npm run init
$ npm start
Expand All @@ -47,19 +42,19 @@ Open your browser and visit http://127.0.0.1:8001 , see more at Development.

## 🤝 Contributing

We welcome all contributions, please read our [CONTRIBUTING.MD](https://github.com/umijs/hooks/blob/master/CONTRIBUTING.MD) first, let's build a better hooks library together.
We welcome all contributions, please read our [CONTRIBUTING.MD](https://github.com/ice-lab/ahooks/blob/master/CONTRIBUTING.MD) first, let's build a better hooks library together.

## 👥 Discuss

<img src="https://raw.githubusercontent.com/umijs/hooks/master/dingtalk.jpg" width="300" />
<img src="https://raw.githubusercontent.com/ice-lab/ahooks/master/dingtalk.jpg" width="300" />

## ✅ License

[MIT](https://github.com/umijs/umi/blob/master/LICENSE)
[MIT](https://github.com/ice-lab/ahooks/blob/master/LICENSE)


[1]: https://www.npmjs.com/package/@umijs/hooks
[2]: https://npmjs.org/package/@umijs/hooks
[1]: https://www.npmjs.com/package/ahooks
[2]: https://npmjs.org/package/ahooks

[image-1]: https://img.shields.io/npm/v/@umijs/hooks.svg?style=flat
[image-2]: https://img.shields.io/npm/dm/@umijs/hooks.svg?style=flat
[image-1]: https://img.shields.io/npm/v/ahooks.svg?style=flat
[image-2]: https://img.shields.io/npm/dm/ahooks.svg?style=flat
28 changes: 11 additions & 17 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[English](https://github.com/umijs/hooks/blob/master/README.md) | 简体中文
[English](https://github.com/ice-lab/ahooks/blob/master/README.md) | 简体中文

# @umijs/hooks
# ahooks

React Hooks Library.

Expand All @@ -18,28 +18,22 @@ React Hooks Library.
* 包含丰富的基础 Hooks。
* 使用 TypeScript 构建,提供完整的类型定义文件。

## 📣 说明

**你可以将 umi hooks 使用在任何地方,和任意组件库搭配使用。**
虽然我们的代码示例都是基于 ant design 的,但是并不代表我们的 Hooks 只能和 ant design 配合使用。


## 📦 安装

```
npm i @umijs/hooks --save
npm i ahooks --save
```

## 🔨使用

```
import { useRequest } from '@umijs/hooks';
import { useRequest } from 'ahooks';
```

## 🖥 开发

```
$ git clone git@github.com:umijs/hooks.git
$ git clone git@github.com:ice-lab/ahooks.git
$ cd hooks
$ npm run init
$ npm start
Expand All @@ -48,18 +42,18 @@ $ npm start

## 🤝 贡献

我们欢迎所有人参与共建,请参考[CONTRIBUTING.MD](https://github.com/umijs/hooks/blob/master/CONTRIBUTING.MD)
我们欢迎所有人参与共建,请参考[CONTRIBUTING.MD](https://github.com/ice-lab/ahooks/blob/master/CONTRIBUTING.MD)

## 👥 讨论

<img src="https://raw.githubusercontent.com/umijs/hooks/master/dingtalk.jpg" width="300" />

## ✅ License

[MIT](https://github.com/umijs/umi/blob/master/LICENSE)
[MIT](https://github.com/ice-lab/ahooks/blob/master/LICENSE)

[1]: https://www.npmjs.com/package/@umijs/hooks
[2]: https://npmjs.org/package/@umijs/hooks
[1]: https://www.npmjs.com/package/ahooks
[2]: https://npmjs.org/package/ahooks

[image-1]: https://img.shields.io/npm/v/@umijs/hooks.svg?style=flat
[image-2]: https://img.shields.io/npm/dm/@umijs/hooks.svg?style=flat
[image-1]: https://img.shields.io/npm/v/ahooks.svg?style=flat
[image-2]: https://img.shields.io/npm/dm/ahooks.svg?style=flat
12 changes: 6 additions & 6 deletions docs/docs/faq.en-US.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# FAQ

Here are the frequently asked questions about Umi Hooks, you should look up before you ask in the community or create a new issue.
Here are the frequently asked questions about ahooks, you should look up before you ask in the community or create a new issue.

### Can I only use Umi Hooks in ant design?
### Can I only use ahooks in ant design?

You can use umi hooks anywhere, with any component library.Although our examples are based on ant design, it does not mean that our Hooks can only be used with ant design.
You can use ahooks anywhere, with any component library.Although our examples are based on ant design, it does not mean that our Hooks can only be used with ant design.

### When I use Umi Hooks, I get an error `regeneratorRuntime is not defined`, how can I solve it?
### When I use ahooks, I get an error `regeneratorRuntime is not defined`, how can I solve it?

```
// install regenerator-runtime
Expand All @@ -16,9 +16,9 @@ npm i regenerator-runtime --save
import "regenerator-runtime/runtime";
```

### I only want to use `useRquest`, but I have to install the entire `@umijs/hooks`?
### I only want to use `useRquest`, but I have to install the entire `ahooks`?

No, `useRequest` is a independent package, can be used by installing `@umijs/use-request` separately.
No, `useRequest` is a independent package, can be used by installing `@ahooksjs/use-request` separately.

### I only want to use one or two of them, but all the hooks are compiled after the project is compiled.

Expand Down
12 changes: 6 additions & 6 deletions docs/docs/faq.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# FAQ

以下整理了一些 Umi Hooks 社区常见的问题和官方答复,在提问之前建议找找有没有类似的问题。
以下整理了一些 ahooks 社区常见的问题和官方答复,在提问之前建议找找有没有类似的问题。

### 我只能在 ant design 中使用 Umi Hooks 吗?
### 我只能在 ant design 中使用 ahooks 吗?

你可以将 umi hooks 使用在任何地方,和任意组件库搭配使用。虽然我们的代码示例都是基于 ant design 的,但是并不代表我们的 Hooks 只能和 ant design 配合使用。
你可以将 ahooks 使用在任何地方,和任意组件库搭配使用。虽然我们的代码示例都是基于 ant design 的,但是并不代表我们的 Hooks 只能和 ant design 配合使用。


### 当我使用 Umi Hooks 时,报错 `regeneratorRuntime is not defined`,如何解决?
### 当我使用 ahooks 时,报错 `regeneratorRuntime is not defined`,如何解决?

```
// 安装 regenerator-runtime
Expand All @@ -17,9 +17,9 @@ npm i regenerator-runtime --save
import "regenerator-runtime/runtime";
```

### 我只想使用 `useRquest`, 但似乎我必须安装整个 `@umijs/hooks`
### 我只想使用 `useRquest`, 但似乎我必须安装整个 `ahooks`

不是的,`useRequest` 在独立包中,可以单独通过安装 `@umijs/use-request` 来使用。
不是的,`useRequest` 在独立包中,可以单独通过安装 `@ahooksjs/use-request` 来使用。

### 我只想用其中一两个 Hooks,但是项目编译后所有的 Hooks 都编译进去了。

Expand Down
18 changes: 9 additions & 9 deletions docs/docs/getting-started.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ nav:

# Getting Started

Umi Hooks is a React Hooks library dedicated to providing commonly used and high quality Hooks.
ahooks is a React Hooks library dedicated to providing commonly used and high quality Hooks.

> Before start, you need to know the basic usage of React and React Hooks. Follow the [link](https://reactjs.org/docs/hooks-intro.html) to learn the official React Hooks documentation.

## First Example

Here is a simple codesandbox example to show the usage of Umi Hooks.
Here is a simple codesandbox example to show the usage of ahooks.


<code src="./demo.tsx" inline />
Expand All @@ -23,13 +23,13 @@ Here is a simple codesandbox example to show the usage of Umi Hooks.

Visit https://codesandbox.io/s/umi-hooks-template-i8jqc to create a codesandbox. Don't forget to press the save button.

### 2. Using Umi Hooks
### 2. Using ahooks

Replace the content of App.js with the following code, use the [useToggle](/state/use-toggle) of Umi Hooks.
Replace the content of App.js with the following code, use the [useToggle](/state/use-toggle) of ahooks.

```javascript
import React from "react";
import { useToggle } from "@umijs/hooks";
import { useToggle } from "ahooks";

export default () => {
const { state, toggle } = useToggle();
Expand All @@ -54,13 +54,13 @@ You can look up Hooks in the side menu like useRequest, useHover etc. Our docume
we can import individual Hooks on demand。

```javascript
import useToggle from '@umijs/hooks/es/useToggle';
import useToggle from 'ahooks/es/useToggle';
```

> Note: Umi Hooks supports ES6 tree shaking, so `import { useToggle } from '@umijs/hooks'` will drop the js code you don't use too.
> Note: ahooks supports ES6 tree shaking, so `import { useToggle } from 'ahooks'` will drop the js code you don't use too.
We strongly recommend using [babel-plugin-import](https://github.com/ant-design/babel-plugin-import), which can convert the following code to the `import useToggle from '@umijs/hooks/es/useToggle'` way:
We strongly recommend using [babel-plugin-import](https://github.com/ant-design/babel-plugin-import), which can convert the following code to the `import useToggle from 'ahooks/es/useToggle'` way:

```javascript
import { useToggle } from '@umijs/hooks';
import { useToggle } from 'ahooks';
```
18 changes: 9 additions & 9 deletions docs/docs/getting-started.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ nav:

# 快速上手

Umi Hooks 是一个 React Hooks 库,致力提供常用且高质量的 Hooks。
ahooks 是一个 React Hooks 库,致力提供常用且高质量的 Hooks。

> 在开始之前,你需要掌握 React 及 React Hooks 基础用法。访问[链接](https://zh-hans.reactjs.org/docs/hooks-intro.html)学习 React Hooks 官方文档。
## 第一个例子

这是一个最简单的 Umi Hooks 的在线 codesandbox 演示。
这是一个最简单的 ahooks 的在线 codesandbox 演示。

<code src="./demo.tsx" inline />

### 1. 创建一个 codesandbox

访问 https://codesandbox.io/s/umi-hooks-template-i8jqc 创建一个 codesandbox 的在线示例,别忘了保存以创建一个新的实例。

### 2. 使用 Umi Hooks
### 2. 使用 ahooks

直接用下面的代码替换 App.js 的内容,使用 Umi Hooks 中的 [useToggle](/zh-CN/state/use-toggle)
直接用下面的代码替换 App.js 的内容,使用 ahooks 中的 [useToggle](/zh-CN/state/use-toggle)

```javascript
import React from "react";
import { useToggle } from "@umijs/hooks";
import { useToggle } from "ahooks";

export default () => {
const { state, toggle } = useToggle();
Expand All @@ -53,15 +53,15 @@ export default () => {
可以通过以下的写法来按需加载 Hooks。

```javascript
import useToggle from '@umijs/hooks/es/useToggle';
import useToggle from 'ahooks/es/useToggle';
```

> 注意:Umi Hooks 默认支持基于 ES module 的 tree shaking,对于 js 部分,直接引入 `import { useToggle } from '@umijs/hooks'` 也会有按需加载的效果。
> 注意:ahooks 默认支持基于 ES module 的 tree shaking,对于 js 部分,直接引入 `import { useToggle } from 'ahooks'` 也会有按需加载的效果。
如果你使用了 babel,那么可以使用 [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 来进行按需加载,加入这个插件后。你可以仍然这么写:

```javascript
import { useToggle } from '@umijs/hooks';
import { useToggle } from 'ahooks';
```

插件会帮你转换成 `@umijs/hooks/es/useToggle` 的写法。
插件会帮你转换成 `ahooks/es/useToggle` 的写法。
12 changes: 6 additions & 6 deletions docs/index.en-US.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: Umi Hooks - React Hooks Library
title: ahooks - React Hooks Library
hero:
title: Umi Hooks
title: ahooks
desc: Born for React Hooks
actions:
- text: Getting Started
link: /docs/getting-started
features:
- icon: https://gw.alipayobjects.com/zos/bmw-prod/813f5ed9-6bc4-43d4-9f74-ec81ecf35733/k7htg6n4_w144_h144.png
title: Rich Collection
desc: Umi Hooks contains a large set of essential react hooks, with demos and examples for each one of them.
desc: ahooks contains a large set of essential react hooks, with demos and examples for each one of them.
- icon: https://gw.alipayobjects.com/zos/bmw-prod/7659205c-6637-4fa2-8529-d32e5818304b/k7htflfb_w144_h144.png
title: Detailed Tutorial
desc: Providing tutorials about using hooks in practice. An all-in-one place to learn for pro coders and newcomers.
Expand All @@ -23,12 +23,12 @@ footer: Open-source MIT Licensed | Copyright © 2019-present<br />Powered by [du

```bash
// Install dependency
npm i @umijs/hooks --save
npm i ahooks --save

// Use Hooks
import { useRequest } from '@umijs/hooks';
import { useRequest } from 'ahooks';
```
## 👥 Feedback
<img src="https://raw.githubusercontent.com/umijs/hooks/master/dingtalk.jpg" width="300" />
<img src="https://raw.githubusercontent.com/ice-lab/ahooks/master/dingtalk.jpg" width="300" />
Loading

0 comments on commit 4ff6fd8

Please sign in to comment.