mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-05-19 09:30:08 +02:00
fix(utils): better method to wrap react classes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user