diff options
author | bobzel <zzzman@gmail.com> | 2023-12-13 21:17:50 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-12-13 21:17:50 -0500 |
commit | 1cf241544f8063e3d71406238a584299b6ced794 (patch) | |
tree | cb2bf6a71abbe76e8e3ab8d6283c0daab850e0a4 /src/client/views/ContextMenuItem.tsx | |
parent | 35f4d108643d310e4e9da107a5839bb74cc6706f (diff) |
cleaned up props/_props handling by inherting from ObservableReactComponent
Diffstat (limited to 'src/client/views/ContextMenuItem.tsx')
-rw-r--r-- | src/client/views/ContextMenuItem.tsx | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/client/views/ContextMenuItem.tsx b/src/client/views/ContextMenuItem.tsx index 59b223c14..3c9d821a9 100644 --- a/src/client/views/ContextMenuItem.tsx +++ b/src/client/views/ContextMenuItem.tsx @@ -5,7 +5,7 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { UndoManager } from '../util/UndoManager'; import { SettingsManager } from '../util/SettingsManager'; -import { copyProps } from '../../Utils'; +import { ObservableReactComponent } from './ObservableReactComponent'; export interface OriginalMenuProps { description: string; @@ -27,24 +27,17 @@ export interface SubmenuProps { export type ContextMenuProps = OriginalMenuProps | SubmenuProps; @observer -export class ContextMenuItem extends React.Component<ContextMenuProps & { selected?: boolean }> { +export class ContextMenuItem extends ObservableReactComponent<ContextMenuProps & { selected?: boolean }> { @observable private _items: Array<ContextMenuProps> = []; @observable private overItem = false; - _prevProps: ContextMenuProps & { selected?: boolean }; - @observable _props: ContextMenuProps & { selected?: boolean }; - constructor(props: ContextMenuProps & { selected?: boolean }) { + constructor(props: any) { super(props); - this._props = this._prevProps = props; makeObservable(this); } - componentDidUpdate() { - copyProps(this); - } - componentDidMount() { - runInAction(() => this._items.length = 0); + runInAction(() => (this._items.length = 0)); if ((this.props as SubmenuProps)?.subitems) { (this.props as SubmenuProps).subitems?.forEach(i => runInAction(() => this._items.push(i))); } |