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

[core] Could useComponentRenderer be exported as a util? #1370

Closed
dpeek opened this issue Jan 30, 2025 · 3 comments · May be fixed by #1418
Closed

[core] Could useComponentRenderer be exported as a util? #1370

dpeek opened this issue Jan 30, 2025 · 3 comments · May be fixed by #1418
Labels
new feature New feature or request

Comments

@dpeek
Copy link

dpeek commented Jan 30, 2025

I'd like to support the same render prop approach to composition for consistency with those provided by base-ui.

Could the useComponentRenderer utility be exported from @base-ui-components/react/utils?

Happy to create a PR if this sounds OK.

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 30, 2025
@zannager zannager added the support: question Community support but can be turned into an improvement label Jan 30, 2025
@mj12albert
Copy link
Member

@dpeek Could you share more about your use-case? I wonder if it may be similar as the use-case for the Slot utility

While discussing that we did consider that a hook may be a better abstraction than <Slot />

However useComponentRenderer is highly tailored for our internal use, so if we do provide this as a hook it would be a simplified version of it

@mj12albert mj12albert linked a pull request Feb 5, 2025 that will close this issue
@mj12albert mj12albert changed the title Could useComponentRenderer be exported as a util? [core] Could useComponentRenderer be exported as a util? Feb 6, 2025
@mj12albert mj12albert added new feature New feature or request status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: question Community support but can be turned into an improvement labels Feb 6, 2025
@mj12albert
Copy link
Member

There's now an open PR with a POC and a sandbox if anybody would like to try it out in the mean time: #1418

@mj12albert mj12albert removed the status: waiting for author Issue with insufficient information label Feb 6, 2025
@dpeek
Copy link
Author

dpeek commented Feb 6, 2025

Wow, thanks for the speedy response, and apologies for not responding in kind!

Yes, my use-case is exactly like the Slot utility in radix, and in fact I was porting some shadcn components and wondering what to do there. I ended up grabbing all the code needed for useComponentRenderer as an interim solution and that worked ok.

I'll give the new hook a try and let you know if I run into any problems.

Thanks again, excited about the future of the project!

@dpeek dpeek closed this as completed Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants