Skip to content

Instantly share code, notes, and snippets.

@jenil94
Created July 25, 2020 16:25
Show Gist options
  • Save jenil94/b33a090fb35bffc50950a7337b7be174 to your computer and use it in GitHub Desktop.
Save jenil94/b33a090fb35bffc50950a7337b7be174 to your computer and use it in GitHub Desktop.
....
import {
format,
startOfWeek,
addDays,
startOfMonth,
endOfMonth,
endOfWeek,
isSameMonth,
isSameDay,
subMonths,
addMonths
} from "date-fns";
const Calendar = () => {
....
const getHeader = () => {
return (
<div class="header">
<div
className="todayButton"
onClick={() => {
setSelectedDate(new Date());
setActiveDate(new Date());
}}
>
Today
</div>
<AiOutlineLeft
className="navIcon"
onClick={() => setActiveDate(subMonths(activeDate, 1))}
/>
<AiOutlineRight
className="navIcon"
onClick={() => setActiveDate(addMonths(activeDate, 1))}
/>
<h2 className="currentMonth">{format(activeDate, "MMMM yyyy")}</h2>
</div>
);
};
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment