import React, {Component, PropTypes} from 'react'; import {Modal, ModalHeader, ModalBody, ModalFooter} from './Modal' class PromptModal extends Component { _onSubmit (e) { e.preventDefault(); this.props.onSubmit(this.refs.input.value); this.refs.modal.close(); } _setDefaultValueFromProps () { if (this.props.defaultValue) { this.refs.input.value = this.props.defaultValue; } } componentDidMount () { this._setDefaultValueFromProps(); } componentDidUpdate () { this._setDefaultValueFromProps(); } render () { const {visible, onClose, submitName, headerName} = this.props; return ( {headerName}
) } } PromptModal.propTypes = { onSubmit: PropTypes.func.isRequired, visible: PropTypes.bool.isRequired, headerName: PropTypes.string.isRequired, defaultValue: PropTypes.string, submitName: PropTypes.string, onClose: PropTypes.func }; export default PromptModal;