Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var NewStatus = React.createClass({
render: function() {
return <div className="new-status">
<h2>New monolog</h2>
<form action="" onSubmit={this.handleSubmit}>
<textarea ref="text" /><br />
<input type="submit" value="Post" />
handleSubmit: function(e) {
var self = this;
var $text = $(React.findDOMNode(this.refs.text));
url: '/status',
type: 'POST',
dataType: 'json',
data: { text: $text.val() },
success: function(data) {
var App = React.createClass({
getInitialState: function() {
return {items: []};
render: function() {
return <div className="app">
<NewStatus onCreate={this.handleCreate} />
<div className="statuses">
<ul>{ {
return <li>{item.text}</li>;
handleCreate: function(data) {
items: this.state.items.concat(data)
React.render(<App />, document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.