Skip to content

Commit

Permalink
fix(core/overrideRegistry): Copy static class properties to Overridab…
Browse files Browse the repository at this point in the history
…le component
  • Loading branch information
christopherthielen committed Mar 7, 2018
1 parent 13d1749 commit 5cf8c4b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/scripts/modules/core/src/overrideRegistry/Overridable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export function Overridable(key: string) {
*/
export function overridableComponent <P extends IOverridableProps, T extends React.ComponentClass<P>> (OriginalComponent: T, key: string): T {
class OverridableComponent extends React.Component<P, { Component: T }> {
public static OriginalComponent: T = OriginalComponent;

private account$ = new Subject<string>();
private destroy$ = new Subject();

Expand Down Expand Up @@ -166,5 +168,10 @@ export function overridableComponent <P extends IOverridableProps, T extends Rea
}
}

// Copy static properties
Object.getOwnPropertyNames(OriginalComponent)
.filter(key => key !== 'constructor' && !OverridableComponent.hasOwnProperty(key))
.forEach(key => (OverridableComponent as any)[key] = (OriginalComponent as any)[key]);

return OverridableComponent as any as T;
}

0 comments on commit 5cf8c4b

Please sign in to comment.