Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(hooks): refactor hooks #4253

Merged
merged 18 commits into from
Nov 29, 2021
Merged

refactor(hooks): refactor hooks #4253

merged 18 commits into from
Nov 29, 2021

Conversation

sxzz
Copy link
Collaborator

@sxzz sxzz commented Nov 5, 2021

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

@sxzz sxzz requested a review from jw-foss November 5, 2021 22:29
@element-bot
Copy link
Member

element-bot commented Nov 5, 2021

@sxzz sxzz requested a review from a team November 7, 2021 17:36
Copy link
Collaborator

@HerringtonDarkholme HerringtonDarkholme left a comment

Choose a reason for hiding this comment

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

LGTM. But I would suggest break large pull requests into separate small changes.
Note this pull requests consists of several different refactors that are readily to be broken up.

if (!isServer) {
on(document, 'keydown', closeModal)
}
if (isClient) useEventListener(document, 'keydown', closeModal)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not side-effect free. Shall we use some init function instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are there any side effects of useEventListener? I didn't get your point.

Copy link
Member

Choose a reason for hiding this comment

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

@HerringtonDarkholme Can you elaborate what the side effect is here?

@sxzz
Copy link
Collaborator Author

sxzz commented Nov 8, 2021

@HerringtonDarkholme Each refactoring corresponds to a commit. I think rebase merge is acceptable. There should be no need for one commit for one pull request.

@sxzz sxzz requested review from HerringtonDarkholme and a team November 11, 2021 23:29
Comment on lines 6 to 10
const registerTimeout = (fn: (...args: any[]) => unknown, delay: number) => {
cancelTimeout()
;({ stop } = useTimeoutFn(fn, delay))
}
const cancelTimeout = () => stop?.()
Copy link
Member

Choose a reason for hiding this comment

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

I think the usage here is wrong, please refer to the source code to get appropriate invoking method.

@sxzz sxzz force-pushed the refactor/hooks branch 3 times, most recently from f6d1054 to 27d5959 Compare November 24, 2021 08:30
Copy link
Member

@jw-foss jw-foss left a comment

Choose a reason for hiding this comment

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

LGTM, let's wait for @HerringtonDarkholme's input.

@jw-foss jw-foss merged commit bbd16a0 into dev Nov 29, 2021
@jw-foss jw-foss deleted the refactor/hooks branch November 29, 2021 07:58
@element-bot element-bot mentioned this pull request Dec 1, 2021
3 tasks
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.

None yet

4 participants