diff options
| author | bobzel <zzzman@gmail.com> | 2023-12-10 20:19:27 -0500 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2023-12-10 20:19:27 -0500 |
| commit | 380ee1acac1c0b7972d7d423cf804af146dc0edf (patch) | |
| tree | 1d77244a600e6eb1fb6d56356b3ce01ca6add89d /src/client/views/ContextMenuItem.tsx | |
| parent | b7b7105fac83ec11480204c5c7ac0ae6579774e1 (diff) | |
massive changes to use mobx 6 which means not accessing props directly in @computed functions.
Diffstat (limited to 'src/client/views/ContextMenuItem.tsx')
| -rw-r--r-- | src/client/views/ContextMenuItem.tsx | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/client/views/ContextMenuItem.tsx b/src/client/views/ContextMenuItem.tsx index 6d97d965e..59b223c14 100644 --- a/src/client/views/ContextMenuItem.tsx +++ b/src/client/views/ContextMenuItem.tsx @@ -1,12 +1,11 @@ import * as React from 'react'; -import { observable, action, runInAction } from 'mobx'; +import { observable, action, runInAction, makeObservable } from 'mobx'; import { observer } from 'mobx-react'; import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { UndoManager } from '../util/UndoManager'; -import { Doc } from '../../fields/Doc'; -import { StrCast } from '../../fields/Types'; import { SettingsManager } from '../util/SettingsManager'; +import { copyProps } from '../../Utils'; export interface OriginalMenuProps { description: string; @@ -32,9 +31,20 @@ export class ContextMenuItem extends React.Component<ContextMenuProps & { select @observable private _items: Array<ContextMenuProps> = []; @observable private overItem = false; - @action + _prevProps: ContextMenuProps & { selected?: boolean }; + @observable _props: ContextMenuProps & { selected?: boolean }; + constructor(props: ContextMenuProps & { selected?: boolean }) { + super(props); + this._props = this._prevProps = props; + makeObservable(this); + } + + componentDidUpdate() { + copyProps(this); + } + componentDidMount() { - 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))); } |
