import * as React from "react" ; import appStore from "../stores/AppStore" ; export class StatusBar extends React . Component < { } , { hasStatus : boolean ; status : string ; } > { constructor ( props ) { super ( props ) ; this . state = { hasStatus : false , status : "" } ; } onDidChangeStatus = ( ) => { this . setState ( { hasStatus : appStore . hasStatus ( ) , status : appStore . getStatus ( ) } ) ; } ; componentDidMount ( ) { appStore . onDidChangeStatus . register ( this . onDidChangeStatus ) ; } componentWillUnmount ( ) { appStore . onDidChangeStatus . unregister ( this . onDidChangeStatus ) ; } render ( ) { let className = "status-bar" ; if ( this . state . hasStatus ) { className += " active" ; } return < div className = { className } > < div className = "status-bar-item" > { this . state . status } < /div> < /div>; } }