Skip to content

Instantly share code, notes, and snippets.

@tribou
Last active October 14, 2015 04:07
Show Gist options
  • Save tribou/de99c3981c35d92507b0 to your computer and use it in GitHub Desktop.
Save tribou/de99c3981c35d92507b0 to your computer and use it in GitHub Desktop.
A sample React component in ES6 using the React style guide
import React from 'react';
import { removeItem } from '../actions/TodoActions.js';
export default class TodoItem extends React.Component {
constructor(props) {
super(props);
this._delete = this._delete.bind(this);
}
_delete() {
removeItem(this.props.index);
}
render() {
return (
<tr>
<td>{this.props.item}</td>
<td>
<button
type="button"
onClick={this._delete}
className="btn btn-link pull-right">
<span
className="glyphicon glyphicon-remove"
aria-hidden="true">
</span>
</button>
</td>
</tr>
);
}
}
TodoItem.propTypes = {
index: React.PropTypes.number,
item: React.PropTypes.string,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment