Skip to content

Instantly share code, notes, and snippets.

@johnthepink
Last active October 27, 2016 00:59
Show Gist options
  • Save johnthepink/e1a74a886f26b39e61295e240b1a5663 to your computer and use it in GitHub Desktop.
Save johnthepink/e1a74a886f26b39e61295e240b1a5663 to your computer and use it in GitHub Desktop.
// 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