fix(renderer): simplify sidebar and reset page errors

This commit is contained in:
ZacharyZhang-NY committed 2026-04-24 10:08:07 -04:00
1 parent eabd304a45
commit 6ce7e63c71
6 files changed
+79 -50

No files matched your search

+25 -3
View File
@@ -66,11 +66,33 @@ export function useReducedMotion() {
/* ErrorBoundary */
/* ------------------------------------------------------------------ */
export class ErrorBoundary extends Component<{ children: ReactNode; fallback?: ReactNode }, { hasError: boolean; error: Error | null }> {
constructor(props: { children: ReactNode; fallback?: ReactNode }) {
type ErrorBoundaryResetKey = string | number | null | undefined;
interface ErrorBoundaryProps {
children: ReactNode;
fallback?: ReactNode;
resetKey?: ErrorBoundaryResetKey;
}
interface ErrorBoundaryState {
hasError: boolean;
error: Error | null;
resetKey: ErrorBoundaryResetKey;
}
export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
constructor(props: ErrorBoundaryProps) {
super(props);
this.state = { hasError: false, error: null };
this.state = { hasError: false, error: null, resetKey: props.resetKey };
}
static getDerivedStateFromProps(props: ErrorBoundaryProps, state: ErrorBoundaryState) {
if (props.resetKey !== state.resetKey) {
return { hasError: false, error: null, resetKey: props.resetKey };
}
return null;
}
static getDerivedStateFromError(error: Error) {
return { hasError: true, error };
}