Skip to content

Commit

Permalink
fix(NoteListLayout): rendering more hooks than previous render (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ComfortablyCoding authored Feb 14, 2024
1 parent 15f98b4 commit a800127
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions admin/src/components/NoteListLayout/NoteListLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <NoteListManager />;
};

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: {
Expand Down

0 comments on commit a800127

Please sign in to comment.