Skip to content

Instantly share code, notes, and snippets.

@alexeyzimarev
Created March 21, 2016 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexeyzimarev/042c40a02b5ed317846a to your computer and use it in GitHub Desktop.
Save alexeyzimarev/042c40a02b5ed317846a to your computer and use it in GitHub Desktop.
TypeScript version of React functional component
/// <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