Best way to show a loading spinner/gif while my React component is fetching via AJAX?

后端 未结 3 520
醉梦人生
醉梦人生 2021-02-06 03:51

Imagine I have a very simple React component that shows a list of elements that are stored in this.state.myList (see example below)

Hitting a \"Refresh\" bu

3条回答
  •  灰色年华
    2021-02-06 04:03

    small edit from @Tom's answer above.

    render: function() {
        return (
            
      { this.state.fetchInProgress ? : this.state.myList.map(function(item) { return
    • {item.name}
    • }) }
    ); }

提交回复
热议问题