Create a reusable Dropdown Menu component #2464
Unanswered
Guignome01
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to customize the Dropdown Menu example to make it reusable like the Popover example with the components
MenuTrigger
andMenuContent
.I assume that it would be used like this but I can't implement a nestable solution with this approach.
The problem is that the
<MenuItem>Item 2</MenuItem>
doesn't share the same context with the otherMenuItem
components since the global provider is in theMenu
component so I don't have access to theactiveIndex
state.I tried to move the provider inside the
MenuContent
component but theMenuTrigger
component doesn't have access to the context that way and any other attempt to extract the logic into multiple hooks/providers failed.Edit : Here is a code sandbox broken demo of what I have done so far.
Beta Was this translation helpful? Give feedback.
All reactions