[Bug]: Error when render <Menu.Button> as a custom component
See original GitHub issueWhat package within Headless UI are you using?
What version of that package are you using?
v1.4.1
What browser are you using?
Chrome
Reproduction repository
https://codesandbox.io/s/wonderful-leaf-t4899?file=/src/App.js
Describe your issue
When trying to use <Menu.Button /> with a custom component it doesn’t work as expected and I get the following warning:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Simplified example:
const CustomButton = ({ children, onClick }) => (
<button onClick={onClick}>{children}</button>
);
<Menu.Button as={CustomButton}>More</Menu.Button>
Does headless-ui require the <CustomButton/>
-component to forward unknown props down to the html <button>
element am I using it wrong?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Adding menu button for Navigation drawer gives error
contentComponent is basically React Component, where you display list ... Sometimes this gives error because of undefined navigation object.
Read more >User error on rendering second level menu items with Layout ...
Basically I'm trying to recreate the blog post seen here https://www.phase2technology.com/blog/creating-mega-menu-layout-builder.
Read more >Custom Button giving error in lightning record page
When I am clicking on cutombutton in lightning it's giving me the below error:- List has no rows for assignment to SObject
Read more >A button in the command bar is not working correctly
Several factors can cause a button action to fail. These include invalid ribbon customizations in which the button's associated command ...
Read more >[Solved] UI Button not working at all - Unity Forum
If anyone else will have a similar problem, select your Canvas GameObject and look at it's components. I had the following: Canvas, Canvas ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
When you are adding custom components, make sure to passthrough all the props you get from Headless UI. These include event handlers, but also aria related attributes.
E.g.:
It might be worth mentioning this in the documentation?