Skip to content

Instantly share code, notes, and snippets.

@kastigar
Created October 11, 2017 11:08
Show Gist options
  • Save kastigar/21432511ee938354a0a06f514f548957 to your computer and use it in GitHub Desktop.
Save kastigar/21432511ee938354a0a06f514f548957 to your computer and use it in GitHub Desktop.
"Data first" example
/*
daysByWeek = [
{ days: [{ number: 31, other: true }, { number: 1 }, { number: 2, current: true }] },
{...},
{...},
]
*/
function Calendar(props) {
const daysByWeek = calculateDaysByWeek(props.date);
return (
<div>
{"..."}
{daysByWeek.map(week => (
<tr>
{week.days.map(day => (
<td>{day.number}</td>
)}
</tr>
)}
{"..."}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment