import React from "react"; import PropTypes from "prop-types"; import SweetAlert from "react-bootstrap-sweetalert"; import { connect } from "react-redux"; import { dismissAlert } from "../../actions/alerts"; const mapStateToProps = state => ({ show: state.alerts.get("show"), title: state.alerts.get("message"), type: state.alerts.get("type") }); const mapDispatchToProps = { dismissAlert }; const Alert = props => { if (!props.show) { return null; } return ( ); }; Alert.propTypes = { show: PropTypes.bool.isRequired, title: PropTypes.string.isRequired, dismissAlert: PropTypes.func.isRequired, type: PropTypes.string }; export default connect(mapStateToProps, mapDispatchToProps)(Alert);