nandorojo / zeego

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

[bug]: android and iOS requires text content requires to be inside `<Text>` tag #99

Closed arpitv96171 closed 2 months ago

arpitv96171 commented 3 months ago

When using just the string, the following error is thrown: Code being used: <ContextMenu.ItemTitle> Redo </ContextMenu.ItemTitle>

Error received:

Screenshot 2024-08-27 at 22 04 23

When using text with the Text tag, the following error is thrown: Code being used: `

Redo ` Error received: Screenshot 2024-08-27 at 21 59 06 Package Versions: React Native: 0.74.5 Expo: 51.0.31 Zeego: 1.10.0
nandorojo commented 3 months ago

You need to share way more code. The original error doesn’t seem to be related to zeego

arpitv96171 commented 2 months ago

@nandorojo

To be specific, the problem appears to be in the packages/zeego/src/menu/create-ios-menu/index.ios.tsx and packages/zeego/src/menu/create-android-menu/index.android.tsx

const ItemTitle = create(({ children }: MenuItemTitleProps) => { if (typeof children != 'string') { throw new Error('[zeego] <ItemTitle /> child must be a string') } return <>{children}</> }, 'ItemTitle')

When a string child is passed, it results in an error due to children not being wrapped in <Text> component for android and iOS. When non-string child is passed, zeego errors with error as mentioned in the code.

nandorojo commented 2 months ago

Please share your full code you used for me to help. You should be passing a string directly to ItemTitle. If you want to pass a text node, then you need to create a custom component using the Custom Components guide in the docs

arpitv96171 commented 2 months ago

Surprisingly it's working alright now. I'll close this issue. I will raise one if any issue comes up in the future