Closed
Description
Environment
- react-native: 0.47.1
- react: 16.0.0-alpha.12
- node: v8.3.0
-
Target Platform:
iOS, android -
Build tools:
create-react-native-app / expo locally, snack.expo.io online.
Steps to Reproduce
Use this code:
import React from 'react';
import { Text, Button } from 'react-native';
class ErrorBoundary extends React.Component {
state = { hasError: false }
componentDidCatch() {
this.setState({ hasError: true })
}
render() {
if (this.state.hasError) {
return <Text>Error in Component</Text>
}
return this.props.children
}
}
const Component = ()=> (
<Button
title="Throw Error!"
onPress={()=> { throw new Error() }}
/>
)
export default ()=> (
<ErrorBoundary>
<Component />
</ErrorBoundary>
)
Expected Behavior
It should behave like react in the browser and display the text "Error in Component".
Actual Behavior
In development mode the red error screen shows. In production the app crashes and restarts.