Skip to content

Instantly share code, notes, and snippets.

@bradharms
Created June 7, 2018 15:53
Show Gist options
  • Save bradharms/f9e3b07dc6060f107c3c9cd96afa4f3a to your computer and use it in GitHub Desktop.
Save bradharms/f9e3b07dc6060f107c3c9cd96afa4f3a to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
type Day = {
dayText : string;
}
type Props = { }
type State = {
days : Day[]
}
function dayToClassNames(day : Day) {
return day.dayText;
}
class Foo extends Component<Props, State> {
handleDayClick(day : Day) {
return () => {
console.log(day);
};
}
render() {
const { days } = this.state;
return <div>
{days.map((day, dayIndex) =>
<td key={dayIndex}>
className={dayToClassNames(day)}
onClick={this.handleDayClick(day)}
>
{day.dayText}
</td>
)}
</div>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment