Created
March 21, 2016 20:12
-
-
Save alexeyzimarev/042c40a02b5ed317846a to your computer and use it in GitHub Desktop.
TypeScript version of React functional component
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
/// <reference path="../typings/browser.d.ts" /> | |
import React, { PropTypes } from 'react'; | |
interface TodoProps { | |
onClick: any; | |
completed: boolean; | |
text: string; | |
} | |
const Todo: React.StatelessComponent<TodoProps> = ({ onClick, completed, text }) => ( | |
<li onClick={ onClick } style = {{ textDecoration: completed ? 'line-through' : 'none' }} > { text } </li> | |
); | |
Todo.propTypes = { | |
onClick: PropTypes.func.isRequired, | |
completed: PropTypes.bool.isRequired, | |
text: PropTypes.string.isRequired | |
} | |
export default Todo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment