From a97d3a97f67ceb64d973aeb9b29efc3f8d363071 Mon Sep 17 00:00:00 2001 From: Soniakeat Date: Wed, 6 Nov 2019 09:20:04 +0100 Subject: [PATCH 1/2] incomplete --- src/App.js | 19 +++------- src/Card.js | 19 ++++++++++ src/ListContacts.js | 84 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 15 deletions(-) create mode 100644 src/Card.js create mode 100644 src/ListContacts.js diff --git a/src/App.js b/src/App.js index 7e261ca47..4c773d17f 100755 --- a/src/App.js +++ b/src/App.js @@ -1,25 +1,14 @@ import React, { Component } from 'react'; -import logo from './logo.svg'; import './App.css'; +import contacts from './data/contacts.json'; +import ListContacts from './ListContacts'; + class App extends Component { render() { return (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+
); } diff --git a/src/Card.js b/src/Card.js new file mode 100644 index 000000000..28cbb8d25 --- /dev/null +++ b/src/Card.js @@ -0,0 +1,19 @@ +import React from 'react'; + +const Card = ({ picture, name, popularity }) => { + return ( + + + + + +

{name}

+ + +

{popularity}

+ + + ) +} + +export default Card; \ No newline at end of file diff --git a/src/ListContacts.js b/src/ListContacts.js new file mode 100644 index 000000000..fd47fb1e3 --- /dev/null +++ b/src/ListContacts.js @@ -0,0 +1,84 @@ +import React, { Component } from 'react'; +import Card from './Card'; +import contacts from './data/contacts.json'; + + +class ListContacts extends Component { + constructor(){ + super(); + this.state = { + contacts: [ + { + "name": "Idris Elba", + "pictureUrl": "https://image.tmdb.org/t/p/w500/d9NkfCwczP0TjgrjpF94jF67SK8.jpg", + "popularity": 11.622713 + }, + { + "name": "Jessica Chastain", + "pictureUrl": "https://image.tmdb.org/t/p/w500/nkFrkn5NZVGWb4b2X0yIcXezhyt.jpg", + "popularity": 8.324357 + }, + { + "name": "Johnny Depp", + "pictureUrl": "https://image.tmdb.org/t/p/w500/kbWValANhZI8rbWZXximXuMN4UN.jpg", + "popularity": 15.656534 + }, + { + "name": "Emilia Clarke", + "pictureUrl": "https://image.tmdb.org/t/p/w500/j7d083zIMhwnKro3tQqDz2Fq1UD.jpg", + "popularity": 16.211837 + }, + { + "name": "Leonardo DiCaprio", + "pictureUrl": "https://image.tmdb.org/t/p/w500/A85WIRIKVsD2DeUSc8wQ4fOKc4e.jpg", + "popularity": 11.245333 + }] + + } + } + + randomContact = () => { + return Math.floor(Math.random() * this.state.contacts.length); + } + + + const contactsCopy = [...this.state.contacts] + contactsCopy.splice(contactIndex, 1); + this.ListeningStateChangedEvent({ + contacts: contactsCopy + }) + + + + + + + render() { + return ( +
+

IronContacts

+ + + + + + + + { + this.state.contacts.map((oneContact, index) => + ) + } + +
PictureNamepopularity
+
+ ) + } +} + + + +export default ListContacts; + +const tableStyle = { + margin: "0 auto" + } \ No newline at end of file From 40f837bfdfe99c31724ca3880e1cacdb0db3407e Mon Sep 17 00:00:00 2001 From: Soniakeat Date: Thu, 7 Nov 2019 00:36:28 +0100 Subject: [PATCH 2/2] incomplete --- src/ListContacts.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ListContacts.js b/src/ListContacts.js index fd47fb1e3..61ef326c8 100644 --- a/src/ListContacts.js +++ b/src/ListContacts.js @@ -42,15 +42,11 @@ class ListContacts extends Component { } - const contactsCopy = [...this.state.contacts] + /* const contactsCopy = [...this.state.contacts] contactsCopy.splice(contactIndex, 1); this.ListeningStateChangedEvent({ contacts: contactsCopy - }) - - - - + }) */ render() {