-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (45 loc) · 1.34 KB
/
Copy pathindex.js
File metadata and controls
53 lines (45 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {AppRegistry, LogBox} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';
// Ignore specific warnings during development
LogBox.ignoreLogs([
'Non-serializable values were found in the navigation state',
]);
// Log any unhandled errors
const ErrorFallback = () => {
const React = require('react');
const {View, Text} = require('react-native');
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff'}}>
<Text style={{fontSize: 18, color: '#000'}}>An error occurred loading the app</Text>
<Text style={{fontSize: 14, color: '#666', marginTop: 8}}>Check the console for details</Text>
</View>
);
};
class ErrorBoundary extends require('react').Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error) {
return { hasError: true };
}
componentDidCatch(error, errorInfo) {
console.error('App Error:', error, errorInfo);
}
render() {
if (this.state.hasError) {
return <ErrorFallback />;
}
return this.props.children;
}
}
const AppWithErrorBoundary = () => {
const React = require('react');
return (
<ErrorBoundary>
<App />
</ErrorBoundary>
);
};
AppRegistry.registerComponent(appName, () => AppWithErrorBoundary);