feat(custom-widgets): complete Custom JSX v2 (#6390)

This commit is contained in:
Thomas authored and GitHub committed 2026-07-22 20:47:19 +02:00
1 parent 60cbd7bb7a
commit 6aceb2fd1f
450 files changed
+39817 -20588

No files matched your search

@@ -8,10 +8,23 @@ export interface PreviewErrorBoundaryProps {
title: string;
description: string;
retryLabel: string;
resetKeys?: readonly unknown[];
}
export class PreviewErrorBoundary extends Component<PreviewErrorBoundaryProps, { hasError: boolean }> {
public state = { hasError: false };
interface PreviewErrorBoundaryState {
hasError: boolean;
resetKeys?: readonly unknown[];
}
export class PreviewErrorBoundary extends Component<PreviewErrorBoundaryProps, PreviewErrorBoundaryState> {
public state: PreviewErrorBoundaryState = { hasError: false, resetKeys: this.props.resetKeys };
public static getDerivedStateFromProps(
props: PreviewErrorBoundaryProps,
state: PreviewErrorBoundaryState,
): Partial<PreviewErrorBoundaryState> | null {
if (!resetKeysChanged(state.resetKeys, props.resetKeys)) return null;
return { hasError: false, resetKeys: props.resetKeys };
}
public static getDerivedStateFromError() {
return { hasError: true };
}
@@ -40,3 +53,9 @@ export class PreviewErrorBoundary extends Component<PreviewErrorBoundaryProps, {
);
}
}
function resetKeysChanged(previous: readonly unknown[] | undefined, current: readonly unknown[] | undefined) {
if (previous === current) return false;
if (!previous || !current || previous.length !== current.length) return true;
return current.some((value, index) => !Object.is(value, previous[index]));
}