import * as React from 'react'; import { Actions, Xml } from './types'; import { updateNode } from './Util'; export enum AskStringType { LONG, SHORT, } interface Props { actions: Actions; defaultValue: string; id: string[]; type: AskStringType; xml: Xml; } interface State { value: string; } export default class AskString extends React.Component { public constructor(props: Props) { super(props); this.onChange = this.onChange.bind(this); this.onSubmit = this.onSubmit.bind(this); this.state = { value: props.defaultValue, }; } public componentDidUpdate(prevProps: Props) { const { defaultValue } = this.props; if (prevProps.defaultValue !== defaultValue) { this.setState({ value: this.props.defaultValue, }); } } public render(): React.ReactNode { const { type } = this.props; return (
{ type === AskStringType.LONG ? this.getLongString() : this.getShortString() }
); } private getShortString(): React.ReactNode { const { value } = this.state; return ( <> ); } private getLongString(): React.ReactNode { const { value } = this.state; return ( <>