Advertisement
DcruzQ

Untitled

Jul 15th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component, Fragment } from "react";
  2. import { withAlert } from "react-alert";
  3. import { connect } from "react-redux";
  4. import PropTypes from "prop-types";
  5.  
  6. export class Alerts extends Component {
  7.   static propTypes = {
  8.     error: PropTypes.object.isRequired,
  9.     message: PropTypes.object.isRequired
  10.   };
  11.  
  12.   //   componentDidUpdate(prevProps) {
  13.   //     const { error, alert, message } = this.props;
  14.   //     if (error !== prevProps.error) {
  15.   //       if (error.msg.name) alert.error(`Name: ${error.msg.name.join()}`);
  16.   //       if (error.msg.email) alert.error(`Email: ${error.msg.email.join()}`);
  17.   //       if (error.msg.message)
  18.   //         alert.error(`Message: ${error.msg.message.join()}`);
  19.   //       if (error.msg.non_field_errors)
  20.   //         alert.error(error.msg.non_field_errors.join());
  21.   //       if (error.msg.username) alert.error(error.msg.username.join());
  22.   //     }
  23.  
  24.   //     if (message !== prevProps.message) {
  25.   //       if (message.deleteLead) alert.success(message.deleteLead);
  26.   //       if (message.addLead) alert.success(message.addLead);
  27.   //       if (message.passwordNotMatch) alert.error(message.passwordNotMatch);
  28.   //     }
  29.   //   }
  30.  
  31.   componentDidMount() {
  32.     this.props.alert.show("It Works!");
  33.   }
  34.   render() {
  35.     return <Fragment />;
  36.   }
  37. }
  38.  
  39. const mapStateToProps = state => ({
  40.   error: state.errors,
  41.   message: state.messages
  42. });
  43.  
  44. export default connect(mapStateToProps)(withAlert(Alerts));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement