В моем реагирующем компоненте я пытаюсь реализовать простой счетчик, пока выполняется запрос ajax - im использует состояние для сохранения состояния загрузки.
По какой-то причине этот фрагмент кода в моем компоненте React вызывает эту ошибку
Может обновлять только смонтированный или монтажный компонент. Обычно это означает вы вызываете setState() на несмонтированном компоненте. Это не-op. Проверьте код для компонента undefined.
Если я избавлюсь от первого вызова setState, ошибка исчезнет.
constructor(props) {
  super(props);
  this.loadSearches = this.loadSearches.bind(this);
  this.state = {
    loading: false
  }
}
loadSearches() {
  this.setState({
    loading: true,
    searches: []
  });
  console.log('Loading Searches..');
  $.ajax({
    url: this.props.source + '?projectId=' + this.props.projectId,
    dataType: 'json',
    crossDomain: true,
    success: function(data) {
      this.setState({
        loading: false
      });
    }.bind(this),
    error: function(xhr, status, err) {
      console.error(this.props.url, status, err.toString());
      this.setState({
        loading: false
      });
    }.bind(this)
  });
}
componentDidMount() {
  setInterval(this.loadSearches, this.props.pollInterval);
}
render() {
    let searches = this.state.searches || [];
    return (<div>
          <Table striped bordered condensed hover>
          <thead>
            <tr>
              <th>Name</th>
              <th>Submit Date</th>
              <th>Dataset & Datatype</th>
              <th>Results</th>
              <th>Last Downloaded</th>
            </tr>
          </thead>
          {
          searches.map(function(search) {
                let createdDate = moment(search.createdDate, 'X').format("YYYY-MM-DD");
                let downloadedDate = moment(search.downloadedDate, 'X').format("YYYY-MM-DD");
                let records = 0;
                let status = search.status ? search.status.toLowerCase() : ''
                return (
                <tbody key={search.id}>
                  <tr>
                    <td>{search.name}</td>
                    <td>{createdDate}</td>
                    <td>{search.dataset}</td>
                    <td>{records}</td>
                    <td>{downloadedDate}</td>
                  </tr>
                </tbody>
              );
          }
          </Table >
          </div>
      );
  }