Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
brickspert committed Nov 5, 2021
1 parent ec4bebe commit d1fb4df
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
12 changes: 6 additions & 6 deletions docs/docs/api.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is ahooks API specification document.
Hooks are allowed to have no output, which is generally common in life cycle Hooks.

```javascript
useMount(()=>{});
useMount(() => {});
```

### 2. value type
Expand All @@ -19,6 +19,7 @@ Hooks have one output value.
```javascript
const documentVisibility = useDocumentVisibility();
```

### 3. value setValue type

The output is value and setValue, the structure is `[value, setValue]` 。
Expand All @@ -37,11 +38,12 @@ const [current, { inc, dec, set, reset }] = useCounter(...);

### 5. values type

The output is multi-value type, the structure is `{...values}` 
The output is multi-value type, the structure is `{...values}`

```javascript
const {text, left, right, ...} = useTextSelection();
```

### 6. values actions type

The output is multi-value and multi-actions type, the structure is `{...values, ...actions}` 。
Expand All @@ -50,7 +52,6 @@ The output is multi-value and multi-actions type, the structure is `{...values,
const {data, error, loading, run} = useRequest(...);
```


## Parameter

In principle, more than two parameters are not allowed.
Expand All @@ -70,12 +71,13 @@ Direct input regardless of whether a single parameter is required.
```javascript
const size = useSize(dom);
```

### 3. Multiple required parameters

The number of required parameters is less than 2, and should be input at the same level.

```javascript
const ref = useKeyPress(keyFilter, eventHandler)
const ref = useKeyPress(keyFilter, eventHandler);
```

If there are more than two, they should be entered as an object.
Expand All @@ -101,5 +103,3 @@ Required parameters are before and non-required parameters are after.
```javascript
const result = useTextSelection(items, defaultSelected?);
```
13 changes: 7 additions & 6 deletions docs/docs/api.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
允许 Hooks 无输出,一般常见于生命周期类 Hooks。

```javascript
useMount(()=>{});
useMount(() => {});
```

### 2. value 型
Expand All @@ -19,6 +19,7 @@ Hooks 输出仅有一个值。
```javascript
const documentVisibility = useDocumentVisibility();
```

### 3. value setValue 型

输出值为 value 和 setValue 类型的,结构为 `[value, setValue]` 。
Expand All @@ -34,13 +35,15 @@ const [state, setState] = useLocalStorageState(...)
```javascript
const [current, { inc, dec, set, reset }] = useCounter(...);
```

### 5. values 型

输出值为多 value 类型的,结构为 `{...values}` 
输出值为多 value 类型的,结构为 `{...values}`

```javascript
const {text, left, right, ...} = useTextSelection();
```

### 6. values actions 型

输出值为多 value 与多 actions 类型的,结构为 `{...values, ...actions}` 。
Expand All @@ -49,7 +52,6 @@ const {text, left, right, ...} = useTextSelection();
const {data, error, loading, run} = useRequest(...);
```


## 参数

原则上不允许超过两个参数。
Expand All @@ -69,12 +71,13 @@ const documentVisibility = useDocumentVisibility();
```javascript
const size = useSize(dom);
```

### 3. 多必选参数

必选参数小于 2 个,应平级输入。

```javascript
const ref = useKeyPress(keyFilter, eventHandler)
const ref = useKeyPress(keyFilter, eventHandler);
```

如果多于 2 个,应以 object 形式输入。
Expand All @@ -100,5 +103,3 @@ const result = useRequest(service, {
```javascript
const result = useTextSelection(items, defaultSelected?);
```
2 changes: 1 addition & 1 deletion packages/hooks/src/useEventTarget/demo/demo2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default () => {
value={value}
onChange={onChange}
style={{ width: 200, marginRight: 20 }}
placeholder="请输入"
placeholder="Please type here"
/>
<button type="button" onClick={reset}>
reset
Expand Down
1 change: 1 addition & 0 deletions packages/hooks/src/useFusionTable/index.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# useFusionTable
1 change: 1 addition & 0 deletions packages/hooks/src/useLongPress/index.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# useLongPress
1 change: 1 addition & 0 deletions packages/hooks/src/usePagination/index.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# usePagination
6 changes: 3 additions & 3 deletions packages/hooks/src/useSafeState/demo/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const Child = () => {

useEffect(() => {
setTimeout(() => {
setValue('从服务端获取的数据');
setValue('data loaded from server');
}, 5000);
}, []);

const text = value || '正在获取数据。。。';
const text = value || 'Loading...';

return <div>{text}</div>;
};
Expand All @@ -20,7 +20,7 @@ export default () => {

return (
<div>
<button onClick={() => setVisible(false)}>卸载</button>
<button onClick={() => setVisible(false)}>Unmount</button>
{visible && <Child />}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useSafeState/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ group:

# useSafeState

It is exactly the same with useState, but after the component is unmount, the setState is no longer executed to avoid memory leakage.
It is exactly the same with `React.useState` , but after the component is unmounted, the `setState` in the asynchronous callback will no longer be executed to avoid memory leakage caused by updating the state after the component is unmounted.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useSafeState/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ group:

# useSafeState

用法与 useState 完全一样,但是在组件卸载后 setState 不再执行,避免因组件卸载后更新状态而导致的内存泄漏。
用法与 `React.useState` 完全一样,但是在组件卸载后异步回调内的 `setState` 不再执行,避免因组件卸载后更新状态而导致的内存泄漏。

## 代码演示

Expand Down

0 comments on commit d1fb4df

Please sign in to comment.