import * as React from 'react'; import { Component, InputHTMLAttributes, SyntheticEvent, } from 'react'; export interface SubmitInputProps extends InputHTMLAttributes { type?: 'text' | 'number'; initialValue?: string; onSubmitValue: (value: string) => void; } export interface SubmitInputState { value: string; } export class SubmitInput extends Component { state: SubmitInputState = { value: '', }; constructor(props: SubmitInputProps) { super(props); this.state.value = props.initialValue || ''; } onSubmit = (event: SyntheticEvent) => { event.preventDefault(); this.props.onSubmitValue(this.state.value); }; render() { return
this.setState({value: event.currentTarget.value})}/>
; } }