diff options
| author | alinayejin <alina_kim@brown.edu> | 2023-12-06 23:35:32 -0500 |
|---|---|---|
| committer | alinayejin <alina_kim@brown.edu> | 2023-12-06 23:35:32 -0500 |
| commit | 173df6c015790e00edd9c9305b1b520b31dc3134 (patch) | |
| tree | d878767cf54ed60311b0984bd7f8b8872c03426d /src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx | |
| parent | d39b3633f3ae1864c89be47b358624e059342d66 (diff) | |
| parent | 7548211c816af70f6c5dfe92897f82527de3986d (diff) | |
Merge branch 'info-ui' of https://github.com/brown-dash/Dash-Web into info-ui
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx index bf47820a1..3c19ef4e9 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx @@ -3,18 +3,11 @@ import { observer } from 'mobx-react'; import './CollectionFreeFormView.scss'; import React = require('react'); -export type infoArc = { - events: () => any; - actions: (arg?: any) => any; +export type infoState = { + Message: string; + Events: () => any; + Actions: (arg?: any) => any; }; -export class infoState { - Message: string = ''; - Arcs: infoArc[] = []; - constructor(message: string, arcs: infoArc[]) { - this.Message = message; - this.Arcs = arcs; - } -} export interface CollectionFreeFormInfoStateProps { state: infoState; @@ -22,28 +15,20 @@ export interface CollectionFreeFormInfoStateProps { @observer export class CollectionFreeFormInfoState extends React.Component<CollectionFreeFormInfoStateProps> { - _disposers: IReactionDisposer[] = []; + _disposer: IReactionDisposer | undefined; + + clearState = () => this._disposer?.(); + initState = () => (this._disposer = reaction(this.props.state.Events, this.props.state.Actions, { fireImmediately: true })); + componentDidMount(): void { - this._disposers = this.props.state.Arcs.map(arc => - reaction( - () => arc.events(), - args => arc.actions(args), - { fireImmediately: true } - ) - ); + this.initState(); } componentWillUpdate() { - this._disposers.map(disposer => disposer()); - this._disposers = this.props.state.Arcs.map(arc => - reaction( - () => arc.events(), - args => arc.actions(args), - { fireImmediately: true } - ) - ); + this.clearState(); + this.initState(); } componentWillUnmount(): void { - this._disposers.map(disposer => disposer()); + this.clearState(); } render() { return <div className="infoUI">{this.props.state.Message}</div>; |
