import React from 'react'; import { connect } from 'react-redux'; import EditPostFormContainer from '../posts/edit_post_form_container'; import { hideModal } from '../../actions/ui_actions'; import { deletePost } from '../../actions/post_actions'; const mapStateToProps = state => ({ modalType: state.ui.modal.modalType, modalProps: state.ui.modal.modalProps }); const mapDispatchToProps = dispatch => ({ hideModal: () => dispatch(hideModal()), deletePost: postId => dispatch(deletePost(postId)) }); class PostModal extends React.Component { constructor(props) { super(props); this.state = { modalIsOpen: false } } render() { if (this.props.modalType === 'edit') { return (
this.props.hideModal()}>×
); } else if (this.props.modalType === 'delete') { return (
this.props.hideModal()}>×
Delete Post
Deleting this post will remove it from your timeline. This action cannot be undone.
); } return null; } } export default connect(mapStateToProps, mapDispatchToProps)(PostModal);