ilya-muhortov
6/6/2019 - 4:28 AM

Обновление по интервалу

import React, {Component} from 'react';

export default class NotificationUnreadCount extends Component {

  constructor(props) {
    super(props);

    this.state = {
      count: null,
      intervalId: null
    };
  }

  update = () => {
  };

  componentDidMount() {
    this.update();
    this.setState({
      intervalId: setInterval(this.update, 30000)
    });
  }

  componentWillUnmount() {
    clearInterval(this.state.intervalId);
  }

  render() {
    return (
      <React.Fragment></React.Fragment>
    );
  }
}