From 7cf45cf3718d6e5295115f28a5f4dd24c6ff14e3 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Fri, 12 Aug 2022 21:24:51 -0400 Subject: [PATCH] feat(Utilities): add wrapReactType utility --- src/utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index 3dcb8e4..c2b3547 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -82,6 +82,11 @@ export function unpatch(obj: any, name: any): void { obj[name] = obj[name].__deckyOrig; } +export function wrapReactType(node: any) { + const oldComponent = node.type; + return node.type = (...args: any[]) => React.createElement(oldComponent, ...args) +} + export function getReactInstance(o: HTMLElement | Element | Node) { return o[Object.keys(o).find(k => k.startsWith('__reactInternalInstance')) as string] }