-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: useLatest | ||
order: 2 | ||
order: 3 | ||
group: | ||
path: /state | ||
nav: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |