nandorojo / zeego

Menus for React (Native) done right.
https://zeego.dev
MIT License
1.68k stars 45 forks source link

Is there any way to lazily create the DropdownMenu items? #114

Open gaearon opened 1 week ago

gaearon commented 1 week ago

I realize this may be a request to react-native-menu, but I'll file here.

Currently we specify dropdown menu content by putting stuff into <DropdownMenu.Content>. The problem is that we have to put it there eagerly. In other words, we have to prepare <DropdownMenu.Item>s in the parent component in case the menu gets opened. The downside is that their event handlers might need certain Hooks (e.g. RQ useMutation) so we end up bloating the parent component render time even if the menu never gets opened.

Ideally I'd like to be able to split the content so that it's lazily initialized, but there doesn't seem to be a way to do that. I was hoping to do something like rendering it conditionally based on state driven by <DropdownMenuRoot onOpenWillChange> but that doesn't seem possible either (the event simply doesn't exist on Android).

Is there any way to achieve what I want?