Guest User

Untitled

a guest
Jul 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. export class Main extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. models: [],
  6. isLoaded: false
  7. };
  8. }
  9.  
  10. componentDidMount() {
  11. fetch(myUrlAPI)
  12. .then(res => res.json())
  13. .then(json => {
  14. this.setState({
  15. isLoaded: true,
  16. models: json
  17. });
  18. });
  19. }
  20.  
  21. render() {
  22. const { isLoaded, models } = this.state;
  23.  
  24. if (!isLoaded) {
  25. return <div>Loading...</div>;
  26. } else {
  27. return (
  28. <div>
  29. <ul>{models.map(model => <li>{model.name}</li>)};</ul>
  30.  
  31. <a href="/sofa">
  32. <div className="Parcelas">
  33. <img
  34. src="../../img/image-card-1@2x.png"
  35. className="ParcImage"
  36. alt="sofa"
  37. />
  38. <h1>Sofa hipnos</h1>
  39. <h2>
  40. 1,200<span>€</span>
  41. </h2>
  42. <p className="Features">
  43. w 20.5 x 15.5 x h 19.5 (cm)<br />Pele
  44. </p>
  45.  
  46. <button className="Botao">
  47. <p className="MostraDepois">See Details</p>
  48. <span>+</span>
  49. </button>
  50. <img
  51. src="../../img/points.svg"
  52. className="Decoration"
  53. alt="points"
  54. />
  55. </div>
  56. </a>
  57. </div>
  58. );
  59. }
  60. }
  61. }
Add Comment
Please, Sign In to add comment