Skip to content

Commit 0758b57

Browse files
committed
Ignore render thru error boundary
1 parent 5dcee0a commit 0758b57

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

packages/react-valibot/src/validateProps.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ export default function validateProps<const TSchema extends BaseSchema<unknown,
4242
props: InferInput<TSchema>,
4343
isolationMode?: IsolationMode | undefined
4444
): InferInput<TSchema> | InferOutput<TSchema> {
45+
// When an error boundary caught an error, React will render some components again with `props` of `undefined`.
46+
if (typeof props === 'undefined') {
47+
// This is probably React rendering while an error is caught, assume it is okay.
48+
return;
49+
}
50+
4551
if (process.env.NODE_ENV === 'production') {
4652
return props as unknown as InferInput<TSchema>;
4753
}
@@ -55,11 +61,12 @@ export default function validateProps<const TSchema extends BaseSchema<unknown,
5561
try {
5662
return parse(propsSchema, props);
5763
} catch (error) {
58-
console.error(
59-
'botframework-webchat: Validation error while parsing props.',
60-
error && typeof error === 'object' && 'issues' in error && error.issues
61-
);
64+
const ourError = new Error('botframework-webchat: Validation error while parsing props.');
65+
66+
console.error(ourError, error && typeof error === 'object' && 'issues' in error && error.issues);
67+
68+
ourError.cause = error;
6269

63-
throw error;
70+
throw ourError;
6471
}
6572
}

0 commit comments

Comments
 (0)