From 8ac02d23903ec95e5230ac99229cb8838a49bed9 Mon Sep 17 00:00:00 2001 From: Cody Bennett Date: Fri, 6 Oct 2023 05:28:57 -0500 Subject: [PATCH] fix(applyProps): loosen copy identity in dev (#3025) --- packages/fiber/src/core/utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/fiber/src/core/utils.ts b/packages/fiber/src/core/utils.ts index 63d04b1aff..9ea7c9b0b3 100644 --- a/packages/fiber/src/core/utils.ts +++ b/packages/fiber/src/core/utils.ts @@ -277,6 +277,8 @@ export function diffProps( return { memoized, changes } } +const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' + // This function applies a set of changes to the instance export function applyProps(instance: Instance, data: InstanceProps | DiffSet) { // Filter equals, events and reserved props @@ -361,7 +363,13 @@ export function applyProps(instance: Instance, data: InstanceProps | DiffSet) { targetProp.copy && value && (value as ClassConstructor).constructor && - targetProp.constructor === (value as ClassConstructor).constructor + // Some environments may break strict identity checks by duplicating versions of three.js. + // Loosen to unminified names, ignoring descendents. + // https://github.com/pmndrs/react-three-fiber/issues/2856 + // TODO: fix upstream and remove in v9 + (__DEV__ + ? targetProp.constructor.name === (value as ClassConstructor).constructor.name + : targetProp.constructor === (value as ClassConstructor).constructor) ) { targetProp.copy(value) }