Add on date change listener
This commit is contained in:
parent
4b12bf0ace
commit
635d851664
|
|
@ -1,5 +1,5 @@
|
||||||
import dayjs from "dayjs";
|
import dayjs, { Dayjs } from "dayjs";
|
||||||
import { useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
import isoWeek from "dayjs/plugin/isoWeek";
|
import isoWeek from "dayjs/plugin/isoWeek";
|
||||||
import customParseFormat from "dayjs/plugin/customParseFormat";
|
import customParseFormat from "dayjs/plugin/customParseFormat";
|
||||||
|
|
@ -18,6 +18,7 @@ type Props = {
|
||||||
events: Event[];
|
events: Event[];
|
||||||
renderCell?: (date: dayjs.Dayjs) => JSX.Element;
|
renderCell?: (date: dayjs.Dayjs) => JSX.Element;
|
||||||
renderEvent?: (event: Event) => JSX.Element;
|
renderEvent?: (event: Event) => JSX.Element;
|
||||||
|
onDateChange?: (date: Dayjs) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Timetable({ events, ...props }: Props) {
|
export default function Timetable({ events, ...props }: Props) {
|
||||||
|
|
@ -47,6 +48,10 @@ export default function Timetable({ events, ...props }: Props) {
|
||||||
});
|
});
|
||||||
}, [currentDate, events]);
|
}, [currentDate, events]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
props.onDateChange?.(currentDate);
|
||||||
|
}, [currentDate, props]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full flex flex-col gap-4">
|
<div className="w-full h-full flex flex-col gap-4">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user