Skip to content

Instantly share code, notes, and snippets.

@GergKllai1
Created May 20, 2019 13:46
Show Gist options
  • Save GergKllai1/ae35ad8b25b0bdf708d3c1e1559417e2 to your computer and use it in GitHub Desktop.
Save GergKllai1/ae35ad8b25b0bdf708d3c1e1559417e2 to your computer and use it in GitHub Desktop.
// src/components/Contact/Contact.js
import React, { Component } from "react";
import { Link } from "react-router-dom";
import { connect } from "react-redux";
import "./Contacts.css";
export class Contacts extends Component {
render() {
const contactList = this.props.contacts.map((el, index) => {
return (
<Link style={{ textDecoration: "none" }} to={`/contact/${index}`}>
<div key={index} className="contact-card">
<h4>{el.name}</h4>
<p>{el.phone}</p>
<p>{el.email}</p>
</div>
</Link>
);
});
return (
<div className="main-container">
{contactList}
<Link style={{ textDecoration: "none" }} to="/contactform">
<button className="add-btn">Add a new Contact</button>
</Link>
</div>
);
}
}
const mapStateToProps = state => {
return {
contacts : state.contacts
}
}
export default connect(mapStateToProps, null)(Contacts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment