import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import { Card } from 'react-bootstrap'; export default class Widget extends Component { constructor(props) { super(props) this.state = { title: this.props.title, value: this.props.value, unit: this.props.unit, icon: this.props.icon } } componentDidUpdate = () => { if(this.props.title != this.state.title || this.props.value != this.state.value || this.props.unit != this.state.unit || this.props.icon != this.state.icon) { this.setState({ title: this.props.title, value: this.props.value, unit: this.props.unit, icon: this.props.icon }); } } render() { var title = this.props.title; var value = this.props.value; var unit = this.props.unit; var icon = this.props.icon; switch(icon) { case 'ping': icon = ; break; case 'dl': icon = ; break; case 'ul': icon = ; break; } return (

{title}

{value}

{unit}

{icon}
); } } if (document.getElementById('Widget')) { ReactDOM.render(, document.getElementById('Widget')); }