Created
June 7, 2018 15:53
-
-
Save bradharms/f9e3b07dc6060f107c3c9cd96afa4f3a to your computer and use it in GitHub Desktop.
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
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