-
Notifications
You must be signed in to change notification settings - Fork 276
Description
Describe the bug
When rendering code conditionally in react-native you can run into a "Text strings must be rendered within a component." error.
Example, which will cause react native app to crash/fail:
const text = 0;
return (
<View style={styles.container}>
{text && <Text>{text}</Text>}
When rendering such a component with render
it will succeed.
Expected behaviour
Expected some form of a crash during rendering too. Instead, the component seems to be rendered successfully.
Steps to Reproduce
I created a reproduction using expo: https://github.com/hannojg/react-native-testing-library-issue
Interestingly it seems that the component can be rendered on the web. However, when you test with expo on iOS/android you will see that the App component can't be rendered.
When you run yarn test
you will see that the test using this library succeeds.
Versions
npmPackages:
@testing-library/react-native: ^7.0.2 => 7.0.2
react: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-39.0.2.tar.gz => 0.63.2
Note: This happens also with bare react native.