import React from "react"; import { Text, TouchableOpacity, View } from "react-native"; import { COLORS } from "@/lib/constants"; interface Props { children: React.ReactNode; screenName: string; } interface State { error: Error | null; } export class ScreenErrorBoundary extends React.Component { state: State = { error: null }; static getDerivedStateFromError(error: Error): State { return { error }; } render() { if (!this.state.error) return this.props.children; return ( {this.props.screenName} hit a snag This screen could not be rendered. The rest of Codexbar is still available. this.setState({ error: null })} className="mt-5 rounded-xl px-4 py-3" style={{ backgroundColor: COLORS.codex }} > Try again ); } }