react-native-ajora
Version:
The most complete AI agent UI for React Native
36 lines • 1.02 kB
JavaScript
import React, { Component } from "react";
import { View, Text, StyleSheet } from "react-native";
export class ErrorBoundary extends Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
componentDidCatch(error, errorInfo) {
console.error("ErrorBoundary caught an error:", error, errorInfo);
}
render() {
if (this.state.hasError) {
return (this.props.fallback || (<View style={styles.container}>
<Text style={styles.text}>Something went wrong.</Text>
</View>));
}
return this.props.children;
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
padding: 20,
},
text: {
fontSize: 16,
color: "#666",
textAlign: "center",
},
});
//# sourceMappingURL=ErrorBoundary.js.map