diff --git a/src/components/AppSidebar.tsx b/src/components/AppSidebar.tsx index 06a9e4c..0904623 100644 --- a/src/components/AppSidebar.tsx +++ b/src/components/AppSidebar.tsx @@ -10,12 +10,28 @@ import ListItem from "./ListItem" import { useNote } from "../contexts/ActiveNoteContext" import { useNotesStore } from "../contexts/NotesStore" import { useTheme } from "../contexts/ThemeContext" +import { ReactNode } from "react" function AppSidebar() { const { notes, createNote } = useNotesStore() - const { setCurrentNote } = useNote() + const { setCurrentNoteId } = useNote() const { theme, toggleTheme } = useTheme() + const buildNoteListItems = () => { + const out: ReactNode[] = [] + notes.forEach((note, key, _) => { + out.push( + setCurrentNoteId(note.id)} + /> + ) + }) + return out; + } + return ( @@ -32,14 +48,7 @@ function AppSidebar() {
- {notes.map((note) => ( - setCurrentNote(note)} - /> - ))} + {buildNoteListItems()}