diff options
Diffstat (limited to 'src/client/views/ObservableReactComponent.tsx')
-rw-r--r-- | src/client/views/ObservableReactComponent.tsx | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/client/views/ObservableReactComponent.tsx b/src/client/views/ObservableReactComponent.tsx index 9b2b00903..34da82b6c 100644 --- a/src/client/views/ObservableReactComponent.tsx +++ b/src/client/views/ObservableReactComponent.tsx @@ -1,6 +1,8 @@ import { action, makeObservable, observable } from 'mobx'; import * as React from 'react'; import './AntimodeMenu.scss'; +import { observer } from 'mobx-react'; +import JsxParser from 'react-jsx-parser'; /** * This is an abstract class that serves as the base for a PDF-style or Marquee-style @@ -14,8 +16,19 @@ export abstract class ObservableReactComponent<T> extends React.Component<T, {}> makeObservable(this); } componentDidUpdate(prevProps: Readonly<T>): void { - Object.keys(prevProps).forEach(action(pkey => - (prevProps as any)[pkey] !== (this.props as any)[pkey] && - ((this._props as any)[pkey] = (this.props as any)[pkey]))); // prettier-ignore + Object.keys(prevProps) + .filter(pkey => (prevProps as any)[pkey] !== (this.props as any)[pkey]) + .forEach(action(pkey => { + (this._props as any)[pkey] = (this.props as any)[pkey]; + })); // prettier-ignore } } + +class ObserverJsxParser1 extends JsxParser { + constructor(props: any) { + super(props); + observer(this as any); + } +} + +export const ObserverJsxParser: typeof JsxParser = ObserverJsxParser1 as any; |