From 3170779c6b3d02ea17f7b6c1fbd57e00498ffe4f Mon Sep 17 00:00:00 2001 From: Tormak <63308171+Tormak9970@users.noreply.github.com> Date: Sun, 25 Jun 2023 17:23:45 -0500 Subject: [PATCH] fix: add patch indicator to prevent crashes --- src/utils/react.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/react.ts b/src/utils/react.ts index 2971364..0e3c2a8 100644 --- a/src/utils/react.ts +++ b/src/utils/react.ts @@ -46,13 +46,17 @@ export function fakeRenderComponent(fun: Function, customHooks: any = {}): any { } export function wrapReactType(node: any, prop: any = 'type') { - return (node[prop] = { ...node[prop] }); + return node[prop].__DECKY_WRAPPED ? node[prop] : (node[prop] = { ...node[prop], __DECKY_WRAPPED: true }); } export function wrapReactClass(node: any, prop: any = 'type') { - const cls = node[prop]; - const wrappedCls = class extends cls {}; - return (node[prop] = wrappedCls); + if (node[prop].__DECKY_WRAPPED) { + return node[prop]; + } else { + const cls = node[prop]; + const wrappedCls = class extends cls { __DECKY_WRAPPED = true; }; + return (node[prop] = wrappedCls); + } } export function getReactInstance(o: HTMLElement | Element | Node) {