import React , { Component } from 'react' ; export abstract class AutoRefreshComponent < P , S > extends Component < P , S > { private intervalHolder : any = null ; getInterval ( ) { return 1000 ; } componentWillMount ( ) { this . intervalHolder = setInterval ( ( ) => this . tick ( ) , this . getInterval ( ) || 1000 ) ; } componentWillUnmount ( ) { this . clearInterval ( ) ; } clearInterval ( ) { clearInterval ( this . intervalHolder ) ; } abstract tick ( ) ; }