From 5b4abf5115aa4583546b0a7da28aeee15033dfaf Mon Sep 17 00:00:00 2001 From: Chris Blanchard Date: Fri, 31 Jul 2015 11:49:39 +0100 Subject: [PATCH] Simplify --- lib/react/user.jsx | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/lib/react/user.jsx b/lib/react/user.jsx index 3b4c9ee..c9e4330 100644 --- a/lib/react/user.jsx +++ b/lib/react/user.jsx @@ -1,18 +1,5 @@ "use strict"; -var UserCounter = React.createClass({ - render: function () { - return ( -
  • - - Online - {this.props.count} - -
  • - ); - } -}); - var UserLogin = React.createClass({ authorizeId: function (id) { id = parseInt(id, 10); @@ -60,19 +47,18 @@ var UserLogin = React.createClass({ var UserMenu = React.createClass({ getDefaultProps: function () { return { - count: 0, users: [] }; }, componentDidMount: function () { - socket.on('users:update', this.updateUsers); - }, - updateUsers: function (data) { - this.setProps({ - count: data.count, - users: data.users + var self = this; + socket.on('users:update', function (data) { + self.setProps({ + users: data.users + }); }); }, + updateUsers: , render: function () { var users = this.props.users.map(function (user) { return ( @@ -81,7 +67,12 @@ var UserMenu = React.createClass({ }); return (