Last active
October 27, 2016 00:59
-
-
Save johnthepink/e1a74a886f26b39e61295e240b1a5663 to your computer and use it in GitHub Desktop.
This file contains 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 characters
// psuedo code | |
class MessageForm extends React.Component { | |
onSubmit = (e) => { | |
// POST the new message | |
} | |
render() { | |
return ( | |
<form onSubmit={this.onSubmit}> | |
<input /> | |
<button type="submit">Submit</button> | |
</form> | |
); | |
} | |
} | |
class Message extends React.Component { | |
render() { | |
return ( | |
<div> | |
<h3>{this.props.message.username}</h3> | |
<p>{this.props.message.body}</p> | |
</div> | |
); | |
} | |
} | |
class MessageContainer extends React.Component { | |
componentDidMount() { | |
// fetch the messages | |
} | |
render() { | |
<div> | |
<MessageForm /> | |
{this.props.messages.map((message) => { | |
return <Message message={message} />; | |
})} | |
</div> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment