From 377d7105c9e1a5196e41ee0a693a030c6a956eb8 Mon Sep 17 00:00:00 2001 From: Afonso Santos Date: Wed, 6 Dec 2023 09:29:38 +0000 Subject: [PATCH] Correct react hook --- apps/app/components/LectureForm/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/app/components/LectureForm/index.js b/apps/app/components/LectureForm/index.js index 0402fe80..741227fd 100644 --- a/apps/app/components/LectureForm/index.js +++ b/apps/app/components/LectureForm/index.js @@ -20,7 +20,7 @@ export default function LectureForm({ id }) { const [selectedMentor, setSelectedMentor] = useState({}); const [selectedNinja, setSelectedNinja] = useState({}); const [selectedEvent, setSelectedEvent] = useState({}); - + const [mentors, setMentors] = useState([]); useEffect(() => { listMentors().then((response) => { @@ -52,10 +52,11 @@ export default function LectureForm({ id }) { }, []); const [ninjas, setNinjas] = useState([]); - const fetchData = useCallback(() => { - let promise; + + const fetchData = useCallback(() => { + let promise; if (!promise) { promise = Promise.all(events.map((event) => getNinjaEvents(event.id))); @@ -74,7 +75,7 @@ export default function LectureForm({ id }) { ) ); }); - }, [fetchData]); + }, [fetchData,events]); const [filteredNinjas, setFilteredNinjas] = useState([]); const handleEventChange = useCallback(