From a800127ce1cf7a346e5ef87e23c67acfb69e63ab Mon Sep 17 00:00:00 2001 From: daedalus <44623501+ComfortablyCoding@users.noreply.github.com> Date: Tue, 13 Feb 2024 20:55:13 -0500 Subject: [PATCH] fix(NoteListLayout): rendering more hooks than previous render (#26) --- .../NoteListLayout/NoteListLayout.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/admin/src/components/NoteListLayout/NoteListLayout.js b/admin/src/components/NoteListLayout/NoteListLayout.js index c4f65eb..5b0de9e 100644 --- a/admin/src/components/NoteListLayout/NoteListLayout.js +++ b/admin/src/components/NoteListLayout/NoteListLayout.js @@ -9,23 +9,28 @@ import NoteModal from '../NoteModal'; import NoteListItem from '../NoteListItem'; const NoteListLayout = () => { - const { isCreatingEntry, modifiedData, slug } = useCMEditViewDataManager(); - const { getNotes } = useNote(); - const { formatMessage } = useIntl(); - const [isNoteModalVisible, setIsNoteModalVisible] = useState(false); - const [activeNote, setActiveNote] = useState({}); - const [notes, setNotes] = useState([]); + const entity = useCMEditViewDataManager(); - if (isCreatingEntry) { + if (entity.isCreatingEntry) { return null; } - const id = modifiedData.id || false; - if (!id) { + if (!entity.modifiedData?.id) { return null; } - const entity = { id, slug }; + return ; +}; + +const NoteListManager = () => { + const { modifiedData, slug } = useCMEditViewDataManager(); + const { getNotes } = useNote(); + const { formatMessage } = useIntl(); + const [isNoteModalVisible, setIsNoteModalVisible] = useState(false); + const [activeNote, setActiveNote] = useState({}); + const [notes, setNotes] = useState([]); + + const entity = { id: modifiedData.id, slug }; const { isLoading, data, isRefetching } = getNotes({ filters: {