diff --git a/.changeset/smart-mails-obey.md b/.changeset/smart-mails-obey.md new file mode 100644 index 00000000..4d7d1004 --- /dev/null +++ b/.changeset/smart-mails-obey.md @@ -0,0 +1,5 @@ +--- +"@playcanvas/react": patch +--- + +Prevents deprecation warnings flooding the console during prop validation diff --git a/packages/lib/src/utils/validation.ts b/packages/lib/src/utils/validation.ts index 282ffcca..5ba72c06 100644 --- a/packages/lib/src/utils/validation.ts +++ b/packages/lib/src/utils/validation.ts @@ -282,7 +282,11 @@ export function getPseudoPublicProps(container: Record): Record // If it's a getter/setter property, try to get the value if (descriptor.get) { + const originalWarn = console.warn; try { + // Temporarily silence the console + console.warn = () => {}; + const value = descriptor.get.call(container); // Create a shallow copy of the value to avoid reference issues const safeValue = value !== null && typeof value === 'object' @@ -300,6 +304,10 @@ export function getPseudoPublicProps(container: Record): Record isDefinedWithSetter: hasSetter }; } + finally { + // Restore the console + console.warn = originalWarn; + } } else if (hasSetter) { // Setter-only property result[key] = {