-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
[core] Refactor data passing #1249
Conversation
Netlify deploy preview |
458923a
to
ee76ae6
Compare
const { | ||
const tooltipRoot = useTooltipRoot({ | ||
...props, | ||
defaultOpen, |
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.
What's the point of passing onOpenChange
, open
, and other props explicitly if they are a part of ...props
?
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.
Yeah, you're right. Forgot that the linting allows unused variables (as they need to be destructured to be documented)
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.
Well not anymore with our latest linting config:
/tmp/base-ui/packages/react/src/popover/root/PopoverRoot.tsx
16:11 error 'defaultOpen' is assigned a value but never used @typescript-eslint/no-unused-vars
16:24 error 'open' is assigned a value but never used @typescript-eslint/no-unused-vars
16:30 error 'onOpenChange' is assigned a value but never used @typescript-eslint/no-unused-vars
...
✖ 12 problems (12 errors, 0 warnings)
Some cases could be simplified even more (less destructuring) if we passed all the props to hooks as they are, without providing default values on a component level. I'm also thinking about reconsidering the context access pattern we use and having the hooks instead of components read context values. This way, we might not need to create new objects just to pass data to hooks as a single parameter. |
Are you referring to |
I mean all our hooks in general (especially the simpler ones). In cases like https://github.com/mui/base-ui/blob/master/packages/react/src/popover/title/PopoverTitle.tsx#L25, we might simplify passing parameters by passing the whole props object to
Yup, we'd have to change the docgen if we wanted to do this. |
2b70f5d
to
ee76ae6
Compare
Signed-off-by: atomiks <[email protected]>
Part of #1246. Focuses just on anchored popups in this PR