-
-
Notifications
You must be signed in to change notification settings - Fork 277
[popups] Refactor useDismiss to use an internal class instance
#3391
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
base: master
Are you sure you want to change the base?
[popups] Refactor useDismiss to use an internal class instance
#3391
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
||
| controller.useSetup(); | ||
|
|
||
| React.useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but here you can save one function allocation:
| React.useEffect(() => { | |
| React.useEffect(controller.disposeEffect); |
Where disposeEffect is:
public disposeEffect() {
return () => {
this.cancelDismissOnEndTimeout.clear();
this.clearInsideReactTreeTimeout.clear();
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disposeEffect = ... for the bound this though. The useTimeout hook is a good model for class-based hooks (and it saves another allocation by using useOnMount instead of useEffect(..., [])). I've been thinking we might want to create a base class for class hooks to standardize and/or manage automatic resource cleanup.
No description provided.