Skip to content

Commit

Permalink
docs(useSetState): add resetState fn
Browse files Browse the repository at this point in the history
  • Loading branch information
coding-ice committed Jan 10, 2024
1 parent 3e7e7b6 commit d427856
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions packages/hooks/src/useSetState/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ useSetState works similar to `this.setState` of class component, used to manage
## API

```typescript
const [state, setState] = useSetState<T>(initialState);
const [state, setState, resetState] = useSetState<T>(initialState);
```

### Result

| Property | Description | Type | Default |
| -------- | -------------------- | ----------------------------------------------------------------------------------------- | ------- |
| state | Current state | `T` | - |
| setState | Update current state | `(state: Partial<T> \| null) => void` \| `((prevState: T) => Partial<T> \| null) => void` | - |
| Property | Description | Type | Default |
| ---------- | -------------------- | ----------------------------------------------------------------------------------------- | ------- |
| state | Current state | `T` | - |
| setState | Update current state | `(state: Partial<T> \| null) => void` \| `((prevState: T) => Partial<T> \| null) => void` | - |
| resetState | Reset current state | `() => void` | - |

### Params

Expand Down
11 changes: 6 additions & 5 deletions packages/hooks/src/useSetState/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ nav:
## API

```typescript
const [state, setState] = useSetState<T>(initialState);
const [state, setState, resetState] = useSetState<T>(initialState);
```

### Result

| 参数 | 说明 | 类型 | 默认值 |
| -------- | ------------ | ----------------------------------------------------------------------------------------- | ------ |
| state | 当前状态 | `T` | - |
| setState | 设置当前状态 | `(state: Partial<T> \| null) => void` \| `((prevState: T) => Partial<T> \| null) => void` | - |
| 参数 | 说明 | 类型 | 默认值 |
| ---------- | ------------ | ----------------------------------------------------------------------------------------- | ------ |
| state | 当前状态 | `T` | - |
| setState | 设置当前状态 | `(state: Partial<T> \| null) => void` \| `((prevState: T) => Partial<T> \| null) => void` | - |
| resetState | 重置当前状态 | `() => void` | - |

### Params

Expand Down

0 comments on commit d427856

Please sign in to comment.