Empty-string children render a text node inside a View in Button, Radio, CheckBox, Toggle (web warning)
Bug Report
Button, Radio, CheckBox and Toggle render their label with {children && (...)} (e.g. ui/button/button.component.tsx, ui/radio/radio.component.tsx). When children is an empty string, '' && ... evaluates to '', and that empty string is rendered as a direct child of the underlying View.
On react-native-web this logs, for every such component:
Unexpected text node: . A text node cannot be a child of a <View>.(the text node is empty; the dot belongs to the message) and leaves an empty text node in the DOM. It is common in practice: a wrapper with title = '' as the default, or an icon-only Button.
To Reproduce
<Button accessoryLeft={StarIcon}>{''}</Button>
<Radio checked>{''}</Radio>Render on web and check the console.
Expected behavior
An empty label renders nothing, as with null or undefined, e.g. {children ? (...) : null} or {!!children && (...)} (keeping 0 in mind if numeric labels should still render).
UI Kitten and Eva version
| Package | Version |
|---|---|
| @ui-kitten/eva | 6.0.2 |
| @ui-kitten/components | 6.1.3 |
Environment information
react-native-web 0.21.2, React 19.2.3, Expo SDK 57 (web and Electron).
Source: akveo/react-native-ui-kitten