Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from "react";
  2. import "./App.css";
  3.  
  4. class App extends Component {
  5.   constructor(props) {
  6.     super(props);
  7.  
  8.     /* DATABASE */
  9.     const movies = [
  10.       {
  11.         id: 0,
  12.         src:
  13.           "https://image.tmdb.org/t/p/w185_and_h278_bestv2/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
  14.         title: "movie one",
  15.         overview: "overview one"
  16.       },
  17.       {
  18.         id: 1,
  19.         src:
  20.           "https://image.tmdb.org/t/p/w185_and_h278_bestv2/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
  21.         title: "movie two",
  22.         overview: "overview two"
  23.       },
  24.       {
  25.         id: 2,
  26.         src:
  27.           "https://image.tmdb.org/t/p/w185_and_h278_bestv2/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
  28.         title: "movie three",
  29.         overview: "overview three"
  30.       }
  31.     ];
  32.  
  33.     let movieRows = [];
  34.  
  35.     /* LOOPING THROUGH DATABASE */
  36.     movies.forEach(item => {
  37.       /* MAKING AN ELEMENT */
  38.       const moveDataTable = (
  39.         <table key={movies.id}>
  40.           <tbody>
  41.             <tr>
  42.               <td>
  43.                 <img alt="poster" width="80" src={movies.src} />
  44.               </td>
  45.               <td>{movies.title}</td>
  46.             </tr>
  47.           </tbody>
  48.         </table>
  49.       );
  50.       /* PUSING DATA TO THE LIST */
  51.       movieRows.push(moveDataTable);
  52.       console.log(movieRows);
  53.     });
  54.  
  55.     this.state = { rows: movieRows };
  56.   }
  57.  
  58.   render() {
  59.     return (
  60.       <div className="App">
  61.         <table className="App-header">
  62.           <tbody>
  63.             <tr>
  64.               <td>
  65.                 <img
  66.                   className="App-logo"
  67.                   alt="app-logo"
  68.                   src="https://cdn3.iconfinder.com/data/icons/social-circle/512/social_4-512.png"
  69.                 />
  70.               </td>
  71.               <td>
  72.                 <h1 className="App-title">MovieDB</h1>
  73.               </td>
  74.             </tr>
  75.           </tbody>
  76.         </table>
  77.         <input className="Search-bar" placeholder="Enter your search term" />
  78.  
  79.         <p> {this.state.rows} </p>
  80.       </div>
  81.     );
  82.   }
  83. }
  84.  
  85. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement