aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
diff options
context:
space:
mode:
authoralinayejin <alina_kim@brown.edu>2023-12-06 23:35:32 -0500
committeralinayejin <alina_kim@brown.edu>2023-12-06 23:35:32 -0500
commit173df6c015790e00edd9c9305b1b520b31dc3134 (patch)
treed878767cf54ed60311b0984bd7f8b8872c03426d /src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoState.tsx
parentd39b3633f3ae1864c89be47b358624e059342d66 (diff)
parent7548211c816af70f6c5dfe92897f82527de3986d (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.tsx41
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>;