I have a really strange behavior in my react-native application. I tracked it down to a minimal example.
I have a SwitchNavigator with two Components. The first Component does nothing except navigating to the second component after 2000ms. The second Component has an error inside the render method (for example it tries to render some undefined stuff "test.error").
Code Component 2:
render = () => {
return (
<View>
{
test.error
}
</View>
)
}
During development I get a normal "redscreen of death" which tells me "ReferenceError: ReferenceError: test is not defined". This is expected behavior. But in release build, the application fails silently and just displays a blank screen. No crash of application.
More Information: The same application does crash in release build (as expected), when the error part is displayed after the component did mount.
Component 2 - crashes as expected:
class Test extends Component {
state = {
error: false
};
componentDidMount = () => {
setTimeout(() => {
this.setState({error: true});
}, 0)
};
render = () => {
if (this.state.error) {
return (
<View>
{
test.error
}
</View>
)
} else {
return (
<View>
Test
</View>
)
}
}
}
Additional information:
- when I use Component 2 as the initially called Component, my application does crash as expected. It seems only not to crash after navigate.
- The behavior is the same with StackNavigator
Versions:
- React: 16.3.1
- ReactNative: 55.4
- ReactNavigation: tried with 1.6.0 and 2.18.2
- Bugsnag: 2.12.4