Last active
October 14, 2015 04:07
-
-
Save tribou/de99c3981c35d92507b0 to your computer and use it in GitHub Desktop.
A sample React component in ES6 using the React style guide
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 characters
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