My issue:
I am trying to add my own styles to the components provided by react-native-popup-menu and add it to my component library. They provide Menu, MenuOptions, and MenuOption components with the following expected hierarchy:
<Menu>
<MenuOptions>
<MenuOption text="A">
</MenuOption>
<MenuOption text="B">
</MenuOption>
</MenuOptions>
</Menu>
I was planning to create wrappers for each of these elements, styling the component within and returning the wrapper when someone imports it from the component library.
For example, a wrapper for the Menu component:
import { MenuProps } from 'react-native-popup-menu';
type CustomMenuProps = {
children: React.ReactElement[];
}
const CustomMenu = (props: MenuProps && CustomMenuProps) => {
return <Menu style={{...someCustomStyle}}>{children}</Menu>
}
This adds the wrapper (an extra element) on each layer resulting in the following hierarchy:
<CustomMenu>
<Menu>
<CustomMenuOptions>
<MenuOptions>...
The package doesnt like this as it depends on the hierarchy to display the menu properly. Throws the error "MenuOptions should be a child of Menu"
Is there a way at all to create a custom styled Menu and expose it as a component in a component library? If it were react, I would have overridden the css classes, but there is no cascading effect in react-native.
Any clues would be very helpful. Thank you.