fix(utils): better method to wrap react classes

This commit is contained in:
AAGaming
2022-08-17 14:51:22 -04:00
parent 9b79f70ac7
commit e644de35d7

View File

@@ -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;
}