Temp(?) note refactors
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
import { createContext, Dispatch, SetStateAction, ReactNode, useContext, useState } from "react";
|
||||
import { Note } from "../models/Note";
|
||||
|
||||
type ActiveNoteType = {
|
||||
currentNote: Note | null;
|
||||
setCurrentNote: Dispatch<SetStateAction<Note | null>>;
|
||||
currentNoteId: string | null;
|
||||
setCurrentNoteId: Dispatch<SetStateAction<string | null>>;
|
||||
}
|
||||
|
||||
const ActiveNote = createContext<ActiveNoteType | null>(null);
|
||||
|
||||
export function NoteProvider({ children }: { children: ReactNode }) {
|
||||
const [currentNote, setCurrentNote] = useState<Note | null>(null);
|
||||
const [currentNoteId, setCurrentNoteId] = useState<string | null>(null);
|
||||
|
||||
return (
|
||||
<ActiveNote.Provider value={{ currentNote, setCurrentNote }}>
|
||||
<ActiveNote.Provider value={{ currentNoteId, setCurrentNoteId }}>
|
||||
{children}
|
||||
</ActiveNote.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user