import React, {Component} from 'react'; import {Toast} from 'react-bootstrap'; import {socket} from "../"; type ToastProps = { title: string, content?: string, bg?: string } type ToastState = { lastUpdated: Date, show: boolean } export class RToast extends Component { state = { lastUpdated: new Date(), show: false } constructor(props: ToastProps) { super(props) } componentDidMount() { socket.on("connect", () => { this.setState({show: true}) }) } tick() { this.setState({lastUpdated: new Date()}) } render() { return ( {this.props.title} {this.state.lastUpdated.toLocaleTimeString('en-GB')} {this.props.content ? {this.props.content} : null} ) } }