Advertisement
Guest User

Untitled

a guest
May 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, PropTypes} from 'react';
  2. //import {Card, CardHeader} from 'material-ui/Card';
  3.  
  4. export class UserConnected extends Component {
  5.   constructor(props) {
  6.     super(props);
  7.     this.state = {
  8.       userCount: '0'
  9.     };
  10.  
  11.   }
  12.  
  13.   componentWillMount() {
  14.     this.props.observableStream.subscribe((x) => {
  15.       //Transform the Payload to a Object
  16.       var count = x.message + '';
  17.       this.setState({userCount: count});
  18.       console.log(this.state.userCount);
  19.     });
  20.   }
  21.  
  22.   shouldComponentUpdate(nextProps, nextState) {
  23.     console.log('Is not being called');
  24.     return true;
  25.   }
  26.  
  27.   render() {
  28.     return (
  29.       <div>
  30.         <h1>HelloWord</h1>
  31.         <h2>IT is {this.state.userCount}</h2>
  32.       </div>
  33.     );
  34.   }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement