diff --git a/core/model/HoistModel.ts b/core/model/HoistModel.ts index 538730216..bd076e23b 100644 --- a/core/model/HoistModel.ts +++ b/core/model/HoistModel.ts @@ -4,9 +4,9 @@ * * Copyright © 2025 Extremely Heavy Industries Inc. */ -import {action, makeObservable, observable} from '@xh/hoist/mobx'; +import {action, computed, comparer, makeObservable, observable} from '@xh/hoist/mobx'; import {warnIf} from '@xh/hoist/utils/js'; -import {forOwn, has, isFunction} from 'lodash'; +import {isFunction} from 'lodash'; import {DefaultHoistProps, HoistBase, LoadSpecConfig, managed, PlainObject} from '../'; import {instanceManager} from '../impl/InstanceManager'; import {Loadable, LoadSpec, LoadSupport} from '../load'; @@ -67,8 +67,7 @@ export abstract class HoistModel extends HoistBase implements Loadable { } // Internal State - @observable - _componentProps = {}; + @observable.ref _componentProps = null; _modelLookup = null; _created = Date.now(); @@ -136,6 +135,7 @@ export abstract class HoistModel extends HoistBase implements Loadable { * Observability is based on a shallow computation for each prop (i.e. a reference * change in any particular prop will trigger observers to be notified). */ + @computed({equals: comparer.shallow}) get componentProps(): DefaultHoistProps { return this._componentProps; } @@ -187,13 +187,7 @@ export abstract class HoistModel extends HoistBase implements Loadable { /** @internal */ @action setComponentProps(newProps) { - const props = this._componentProps; - Object.assign(props, newProps); - forOwn(props, (v, k) => { - if (!has(newProps, k)) { - delete props[k]; - } - }); + this._componentProps = newProps; } /** @internal */