From e644de35d70680d17d70e89cc9b929a5aae08b48 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Wed, 17 Aug 2022 14:51:22 -0400 Subject: [PATCH] fix(utils): better method to wrap react classes --- src/utils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index 42fdfe5..bfe5a07 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -89,6 +89,13 @@ export function wrapReactType(node: any, prop?: any) { export function wrapReactClass(node: any, prop?: any) { const cls = node[prop || "type"]; const wrappedCls = class extends cls {}; + Object.getOwnPropertyNames(cls.prototype).forEach((prop: any) => { + wrappedCls.prototype[prop] = cls.prototype[prop] + }); + Object.getOwnPropertyNames(cls).forEach((prop: any) => { + if (prop != "prototype") wrappedCls[prop] = cls[prop] + }); + wrappedCls.prototype.__proto__ = cls.prototype.__proto__; return node[prop || "type"] = wrappedCls; }