Skip to content

Commit 98dc81c

Browse files
authored
Suppress Engine deprecation warnings (#257)
* Enhance getPseudoPublicProps function to temporarily silence console warnings during property retrieval * Implement changeset to prevent deprecation warnings during prop validation for @playcanvas/react
1 parent ec4a1ce commit 98dc81c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/smart-mails-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@playcanvas/react": patch
3+
---
4+
5+
Prevents deprecation warnings flooding the console during prop validation

packages/lib/src/utils/validation.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ export function getPseudoPublicProps(container: Record<string, unknown>): Record
282282

283283
// If it's a getter/setter property, try to get the value
284284
if (descriptor.get) {
285+
const originalWarn = console.warn;
285286
try {
287+
// Temporarily silence the console
288+
console.warn = () => {};
289+
286290
const value = descriptor.get.call(container);
287291
// Create a shallow copy of the value to avoid reference issues
288292
const safeValue = value !== null && typeof value === 'object'
@@ -300,6 +304,10 @@ export function getPseudoPublicProps(container: Record<string, unknown>): Record
300304
isDefinedWithSetter: hasSetter
301305
};
302306
}
307+
finally {
308+
// Restore the console
309+
console.warn = originalWarn;
310+
}
303311
} else if (hasSetter) {
304312
// Setter-only property
305313
result[key] = {

0 commit comments

Comments
 (0)