From d237bd48e4b9e6436d7daefdf70327875e9e940d Mon Sep 17 00:00:00 2001 From: AAGaming Date: Wed, 17 Aug 2022 14:45:34 -0400 Subject: [PATCH] feat(utils): add wrapReactClass --- src/utils.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index a1d0fb0..42fdfe5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -82,8 +82,14 @@ export function unpatch(obj: any, name: any): void { obj[name] = obj[name].__deckyOrig; } -export function wrapReactType(node: any) { - return node.type = {...node.type} +export function wrapReactType(node: any, prop?: any) { + return node[prop || "type"] = {...node[prop || "type"]}; +} + +export function wrapReactClass(node: any, prop?: any) { + const cls = node[prop || "type"]; + const wrappedCls = class extends cls {}; + return node[prop || "type"] = wrappedCls; } export function getReactInstance(o: HTMLElement | Element | Node) {