Created
January 18, 2016 16:22
-
-
Save wontwon/f977a209faf00771ddcc to your computer and use it in GitHub Desktop.
Revisions
-
wontwon created this gist
Jan 18, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ import React from 'react'; import ChatLine from './chat-line'; const ChatLog = React.createClass({ getInitialState: function() { console.log('initial state'); return { lines: [] }; }, addMessage: function(msg) { console.log('add message'); msg.id = this.state.lines.length; this.state.lines.push(msg); this.render(); console.log(this.state); }, render: function() { console.log(this.state); var chatLine = this.state.lines.map(function(line) { <ChatLine key={line.id} user={line.user} msg={line.msg} /> }); return ( <div> {chatLine} </div> ); } }); export default ChatLog;