[javascript] ciapo

Viewer

  1. import React, { Component } from 'react';
  2. import { Button } from '../../components';
  3.  
  4. export default class Home extends Component {
  5.   constructor(props) {
  6.     super(props);
  7.     this.state = { 
  8.       breedList: [],
  9.       loading: true
  10.     };
  11.   }
  12.  
  13.   componentDidMount() {
  14.     this.formatComponent();
  15.   }
  16.  
  17.   formatComponent() {
  18.     this.makeBreedList();
  19.  
  20.     this.setState({
  21.       loading: false,
  22.     });
  23.   }
  24.  
  25.   makeBreedList() {
  26.     const breedList = [];
  27.  
  28.     // for ...
  29.  
  30.     this.setState({
  31.       breedList
  32.     });
  33.   }
  34.  
  35.   render() {
  36.  
  37.     const { breedList, loading } = this.state;
  38.  
  39.     return ( 
  40.       <main>
  41.         {(loading === false) ? (
  42.           <section>
  43.             <h1>YOUR STUFF HERE</h1>
  44.  
  45.           </section>
  46.         ) : (
  47.           <h1> LOADING... </h1>
  48.         )}
  49.       </main>
  50.     );
  51.   }
  52. }

Editor

You can edit this paste and save as new:


File Description
  • ciapo
  • Paste Code
  • 02 Jun-2020
  • 854 Bytes
You can Share it: