src/App.js
//this will run the first time the component mounts
this will run the first time the component mounts
this will run the first time the component mounts
async componentDidMount() {
    if (this.state.searchQuery === '') {
      await fetch('http://localhost:3001/emails')
        .then(response => response.json())
        .then(data => this.setState({emailList: data, emailSelected: false}));
      } else {
        await fetch(`http://localhost:3001/search?query=${this.state.searchQuery}`)
          .then(response => response.json())
          .then(data => this.setState({emailList: data, emailSelected: false}));
      }
  }
async componentDidMount ( ) { if ( this . state . searchQuery === '' ) { await fetch ( 'http://localhost:3001/emails' ) . then ( response => response . json ( ) ) . then ( data => this . setState ( { emailList : data , emailSelected : false } ) ) ; } else { await fetch ( ` ${ this . state . searchQuery } ` ) . then ( response => response . json ( ) ) . then ( data => this . setState ( { emailList : data , emailSelected : false } ) ) ; } }
this will run the first time the component mounts
this will run the first time the component mounts