add context hooks and fix new window not appear
This commit is contained in:
21
src/hooks/theme-events.tsx
Normal file
21
src/hooks/theme-events.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
'use client'
|
||||
|
||||
import { EventsDate } from "@/lib/types";
|
||||
import { getEvent } from "@/lib/utils";
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
interface ThemeEventsContextType {
|
||||
event: EventsDate | undefined
|
||||
}
|
||||
|
||||
const ThemeEventsContext = createContext<ThemeEventsContextType | undefined>(undefined);
|
||||
|
||||
export const ThemeEventsProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const eventNow = getEvent();
|
||||
|
||||
return <ThemeEventsContext.Provider value={{ event: eventNow }}>
|
||||
{children}
|
||||
</ThemeEventsContext.Provider>
|
||||
}
|
||||
|
||||
export const useThemeEvents = () => useContext(ThemeEventsContext);
|
||||
Reference in New Issue
Block a user