import PropTypes from "prop-types"; import React from "react"; import Modal from "./Modal"; class TextInputModal extends React.Component { static propTypes = { title: PropTypes.string.isRequired, label: PropTypes.string.isRequired, show: PropTypes.bool.isRequired, callback: PropTypes.func.isRequired, initialValue: PropTypes.string, }; componentDidUpdate() { if (this.props.initialValue) { this.textInput.value = this.props.initialValue; } } onSubmit() { this.props.callback(this.textInput.value); this.textInput.value = ""; } onCancel() { this.props.callback(undefined); this.textInput.value = ""; } render() { return (
{ e.preventDefault(); this.onSubmit(); }}>
this.textInput = textInput}/>
); } } export default TextInputModal;