diff options
author | bobzel <zzzman@gmail.com> | 2023-12-14 00:07:52 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-12-14 00:07:52 -0500 |
commit | cebe9d2a567c20b99c8c394cfa598ee9d4d53ece (patch) | |
tree | c33df9a3dc80cb199002610cc38645976023eff9 /src/client/views/ObservableReactComponent.tsx | |
parent | 1cf241544f8063e3d71406238a584299b6ced794 (diff) |
a bunch more fixes to making things observable. fixed calling super.componentDidUpdate on subsclasses
Diffstat (limited to 'src/client/views/ObservableReactComponent.tsx')
-rw-r--r-- | src/client/views/ObservableReactComponent.tsx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/client/views/ObservableReactComponent.tsx b/src/client/views/ObservableReactComponent.tsx index 2d8dc9af9..9b2b00903 100644 --- a/src/client/views/ObservableReactComponent.tsx +++ b/src/client/views/ObservableReactComponent.tsx @@ -1,8 +1,6 @@ -import { makeObservable, observable } from 'mobx'; +import { action, makeObservable, observable } from 'mobx'; import * as React from 'react'; -import { copyProps } from '../../Utils'; import './AntimodeMenu.scss'; -export interface AntimodeMenuProps {} /** * This is an abstract class that serves as the base for a PDF-style or Marquee-style @@ -10,12 +8,14 @@ export interface AntimodeMenuProps {} */ export abstract class ObservableReactComponent<T> extends React.Component<T, {}> { @observable _props: React.PropsWithChildren<T>; - constructor(props: React.PropsWithChildren<T>) { + constructor(props: any) { super(props); this._props = props; makeObservable(this); } componentDidUpdate(prevProps: Readonly<T>): void { - copyProps(this, prevProps); + 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 } } |