var UIMessages = React.createClass({ getInitialState: function () { return { messages: [], from: undefined, to: undefined, type: undefined }; }, componentDidMount: function () { var self = this; notificationCenter.subscribe(Notifications.data.MESSAGE_DATA_CHANGE, function() { var messages = []; if(messageModel.data != undefined) messages = messageModel.data.messages; self.setState({messages: messages, from: messageModel.from, to: messageModel.to, type: messageModel.type }); }); messageModel.downloadMessages(); /* messageModel.fetchData("data/message.json"); setTimeout(function() { messageModel.fetchData("data/message.json"); }, 10000) */ }, render: function () { var self = this; var messages = this.state.messages.map(function(message, index) { var date = new Date(message.date); return (