-
Notifications
You must be signed in to change notification settings - Fork 25k
Closed
Labels
BugJavaScriptStaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.
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.
Reproducible Demo
easybird, xcarpentier, hellogerard, pietro909, janziemba and 15 morehellogerard, enthal, mfpiccolo, FrankGoortani and victorkurauchi
Metadata
Metadata
Assignees
Labels
BugJavaScriptStaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.