You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
homepage/src/utils/contexts/calendar.jsx

29 lines
798 B

import { createContext, useState, useMemo } from "react";
export const EventContext = createContext();
export const ShowDateContext = createContext();
export function EventProvider({ initialEvent, children }) {
const [events, setEvents] = useState({});
if (initialEvent) {
setEvents(initialEvent);
}
const value = useMemo(() => ({ events, setEvents }), [events]);
return <EventContext.Provider value={value}>{children}</EventContext.Provider>;
}
export function ShowDateProvider({ initialDate, children }) {
const [showDate, setShowDate] = useState(null);
if (initialDate) {
setShowDate(initialDate);
}
const value = useMemo(() => ({ showDate, setShowDate }), [showDate]);
return <ShowDateContext.Provider value={value}>{children}</ShowDateContext.Provider>;
}