import * as React from "react" ; import { isNodeEnv } from "./utils" ; deprecated export abstract class AbstractComponent < P , S > extends React . Component < P , S > { /** Component displayName should be `public static`. This property exists to prevent incorrect usage. */ protected displayName : never ; private timeoutIds : number [ ] = [ ] ; constructor ( props , context ? ) { super ( props , context ) ; if ( ! isNodeEnv ( "production" ) ) { this . validateProps ( this . props ) ; } } public componentWillReceiveProps ( nextProps ) { if ( ! isNodeEnv ( "production" ) ) { this . validateProps ( nextProps ) ; } } public componentWillUnmount ( ) { this . clearTimeouts ( ) ; } returns public setTimeout ( callback , timeout ? ) { const handle = window . setTimeout ( callback , timeout ) ; this . timeoutIds . push ( handle ) ; return ( ) => window . clearTimeout ( handle ) ; } /**
     * Clear all known timeouts.
     */ public clearTimeouts = ( ) => { if ( this . timeoutIds . length > 0 ) { for ( const timeoutId of this . timeoutIds ) { window . clearTimeout ( timeoutId ) ; } this . timeoutIds = [ ] ; } } ; /**
     * Ensures that the props specified for a component are valid.
     * Implementations should check that props are valid and usually throw an Error if they are not.
     * Implementations should not duplicate checks that the type system already guarantees.
     *
     * This method should be used instead of React's
     * [propTypes](https://facebook.github.io/react/docs/reusable-components.html#prop-validation) feature.
     * Like propTypes, these runtime checks run only in development mode.
     */ protected validateProps ( _ ) { } }