aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/ObservableReactComponent.tsx
blob: 2d8dc9af95205b8c2b8ce13b241d98407f3ab553 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { makeObservable, observable } from 'mobx';
import * as React from 'react';
import { copyProps } from '../../Utils';
import './AntimodeMenu.scss';
export interface AntimodeMenuProps {}

/**
 * This is an abstract class that serves as the base for a PDF-style or Marquee-style
 * menu. To use this class, look at PDFMenu.tsx or MarqueeOptionsMenu.tsx for an example.
 */
export abstract class ObservableReactComponent<T> extends React.Component<T, {}> {
    @observable _props: React.PropsWithChildren<T>;
    constructor(props: React.PropsWithChildren<T>) {
        super(props);
        this._props = props;
        makeObservable(this);
    }
    componentDidUpdate(prevProps: Readonly<T>): void {
        copyProps(this, prevProps);
    }
}