Skip to content

Commit

Permalink
docs: 更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
llq0802 committed Oct 25, 2022
1 parent febcdc3 commit 6c09d10
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 2 deletions.
14 changes: 13 additions & 1 deletion config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ const configs = defineConfig({
},
{
title: 'state',
children: ['useCallbackState/index.md', 'useLatest/index.md'],
children: ['useCallbackState/index.md', 'useLatest/index.md', 'usePrevious/index.md'],
},
{
title: 'effect',
children: ['useUpdateEffect/index.md'],
},
{
title: 'dom',
children: ['useClientRect/index.md'],
},
{
title: 'other',
children: ['useDebounceFn/index.md'],
},
],
},
Expand Down
23 changes: 23 additions & 0 deletions packages/rc-use-hooks/src/useClientRect/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: useClientRect
order: 3
group:
path: /dom
nav:
order: 3
path: /hooks
---

# useClientRect

返回最新的 state 或 props 避免闭包问题。

## 代码演示

<!-- <code src='./demos/demo1.tsx' /> -->

## API

```typescript
const latestValue = useLatest(value);
```
23 changes: 23 additions & 0 deletions packages/rc-use-hooks/src/useDebounceFn/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: useDebounceFn
order: 3
group:
path: /other
nav:
order: 3
path: /hooks
---

# useDebounceFn

返回最新的 state 或 props 避免闭包问题。

## 代码演示

<!-- <code src='./demos/demo1.tsx' /> -->

## API

```typescript
const latestValue = useLatest(value);
```
2 changes: 1 addition & 1 deletion packages/rc-use-hooks/src/useLatest/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: useLatest
order: 2
order: 3
group:
path: /state
nav:
Expand Down
21 changes: 21 additions & 0 deletions packages/rc-use-hooks/src/usePrevious/demos/demo1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Button } from 'antd';
import { usePrevious } from 'rc-use-hooks';
import { useState } from 'react';

const demo1 = () => {
const [count, setCount] = useState(0);
const prevCount = usePrevious(count);
const onClick = () => {
setCount(count + 1);
};
return (
<>
<Button onClick={onClick}>点击</Button>

<div> 上一次count:{prevCount}</div>
<div> 当前count:{count}</div>
</>
);
};

export default demo1;
23 changes: 23 additions & 0 deletions packages/rc-use-hooks/src/usePrevious/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: usePrevious
order: 3
group:
path: /state
nav:
order: 3
path: /hooks
---

# usePrevious

用于获取状态上一次的值

## 代码演示

<code src='./demos/demo1.tsx' />

### API

```typescript
const prevValue = usePrevious(value);
```
23 changes: 23 additions & 0 deletions packages/rc-use-hooks/src/useSetSate/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: useSetSate
order: 3
group:
path: /other
nav:
order: 3
path: /hooks
---

# useDebounceFn

返回最新的 state 或 props 避免闭包问题。

## 代码演示

<!-- <code src='./demos/demo1.tsx' /> -->

## API

```typescript
const latestValue = useLatest(value);
```
23 changes: 23 additions & 0 deletions packages/rc-use-hooks/src/useUpdateEffect/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: useUpdateEffect
order: 3
group:
path: /effect
nav:
order: 3
path: /hooks
---

# useUpdateEffect

返回最新的 state 或 props 避免闭包问题。

## 代码演示

<!-- <code src='./demos/demo1.tsx' /> -->

## API

```typescript
const latestValue = useLatest(value);
```

0 comments on commit 6c09d10

Please sign in to comment.