Grégoire Delattre c5cafacbf1 Update everything to work with the new router
By the way, remove the router state from redux.
2019-05-19 02:31:25 +02:00

36 lines
830 B
JavaScript

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 (
<SweetAlert
type={props.type}
title={props.title}
onConfirm={props.dismissAlert}
/>
)
}
Alert.propTypes = {
show: PropTypes.bool.isRequired,
title: PropTypes.string.isRequired,
dismissAlert: PropTypes.func.isRequired,
type: PropTypes.string,
};
export default connect(mapStateToProps, mapDispatchToProps)(Alert);