Repository navigation
[popups] Refactor useDismiss to use an internal class instance - #3391
michaldudak wants to merge 12 commits into
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
||
| controller.useSetup(); | ||
|
|
||
| React.useEffect(() => { |
There was a problem hiding this comment.
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.
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.
|
After #4661, there's no more noticeable improvement in the mount time of this PR. |
No description provided.