import { createContext, Dispatch, SetStateAction, ReactNode, useContext, useState } from "react"; type ActiveNoteType = { currentNoteId: string | null; setCurrentNoteId: Dispatch>; } const ActiveNote = createContext(null); export function NoteProvider({ children }: { children: ReactNode }) { const [currentNoteId, setCurrentNoteId] = useState(null); return ( {children} ); } export function useNote() { const context = useContext(ActiveNote); if (!context) throw new Error("useNote must be used from within ActiveNote.Provider") return context; }