Skip to content

Conversation

@LaughSun0513
Copy link
Contributor

1.修复hook表格内路由跳转异常问题,修改路由模式为browser
2.删除文件夹目录docs/docks, 改为平铺
3.翻译部分Hook为中文,useArray/useClickOutside/useBoolean

# useActionPending

当你传递一个异步函数给这个hook时,它会返回一个封装后的函数和一个异步进行中”数量
当你传递一个异步函数给这个hook时,它会返回一个封装后的函数和一个"异步进行中"的数量
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在中文里,是不是应该用中文的双引号?

```

在返回的元组中,第二项称为`pendingCount`,你可以简单地用`!!pendingCount`来判断是否还有未完成的异步,并在界面上表现为一个加载中的视图。
在返回的元组中,第二项称为`pendingCount`,你可以简单地用`!!pendingCount`来判断是否还有未完成的异步,并在界面上表现为一个"加载中"的视图。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上


```typescript
interface BooleanMethods {
// Change value to true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些注释,也翻译一下呗


# useElementResize

当元素调整大小时会触发一个回调函数。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的“一个”其实没必要写,看起来就特别生硬

function useElementResize(callback: (element: HTMLElement) => void): ElementResizeCallback;
```

为了确保所有改变的元素都能被捕获,甚至元素类型改变(从`<div>`标签修改为`<span>`标签),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确保React元素上的所有变化都能监听到,包括元素类型改变

function useElementSize(): [ElementResizeCallback, Size | undefined];
```

初始值是`undefined` 当元素改变的时候会更新尺寸大小。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里好像多了个空格


<code src='./demo/useHover.tsx'>

注意, 当你给 `delay`参数传了个正数时,`onEnter``onLeave`的回调都是已经防抖过的,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里反而前面多了个空格,空格的规则保持一致吧,要加就都加,要么就都不加(我的习惯是不加)

function useImmerState<S = any>(initialState: S | (() => S)): ImmerState<S>;
```

这与`useState`的工作原理完全相同,唯一不同的是,当一个函数被传递给`setState`时,它可以直接改变状态。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的逗号都是半角的了

function useImmerState<S = any>(initialState: S | (() => S)): ImmerState<S>;
```

这与`useState`的工作原理完全相同,唯一不同的是,当一个函数被传递给`setState`时,它可以直接改变状态。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接改变状态 -> 可以直接修改当前的状态对象来更新状态值

```

`useInfiniteScroll`中的`fetch`函数接收一个对象, 其中`offset`属性默认0, 表示下一页的起始索引。
如果你有一个函数需要`pageIndex`来工作,`offset / pageSize`都指向`pageIndex`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

都指向 -> 等于

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants