import * as React from 'react' ; import Text , { Props as TextProps } from '../Text' ; export interface TickerProps extends TextProps { seconds : number ; } const Ticker = props => { const [ seconds , setSeconds ] = React . useState ( props . seconds ) ; React . useEffect ( ( ) => { let timeout ; if ( seconds > 0 ) { timeout = setTimeout ( ( ) => setSeconds ( seconds - 1 ) , 1000 ) ; } return ( ) => clearTimeout ( timeout ) ; } , [ seconds ] ) ; return < Text { ... props } > { seconds } < /Text>; } ; export default Ticker ;