New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Text strings must be rendered within a <Text> component. #31273
Comments
Solved. need to use ternary operator |
Hello, looks like you found the solution! |
use !!imageUri && |
Looks like the string it's complaining about is the empty string at The error is intentional; it's not obvious that this is a bug in React Native, and you've found a solution. Seems like the issue should be closed. |
Do empty strings still cause this I can't seem to reproduce this (on Snack with Expo). The following does not cause crashes: export default function App() {
const name = '';
return (
<View style={styles.container}>
{name && <Text>name: {name}</Text>}
{''}
<Text>no crashes</Text>
</View>
);
} |
Seems like they do not cause issues anymore with React Native 0.70.1: I just started a new React Native app just now ( Whereas a string with content in it does: |
Empty strings indeed no longer cause errors (if you use React 18+): |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Do you still experience this issue? I have four years of experience maintaining facebook/react-native and I specialize in the Text and TextInput components. I currently have 58 facebook/react-native PRs. If you still experience this issue, I will prepare a patched release with the fix. Thanks a lot |
The text was updated successfully, but these errors were encountered: