From 52308af74d6b9855d08c08cd7cfcf5f5b8f3406d Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 4 Apr 2021 09:45:20 -0700 Subject: [PATCH] Normalize this code. --- .../server/schedules/ScheduleEditContainer.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx index 8fcb91af..df0af5b9 100644 --- a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx +++ b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx @@ -46,9 +46,9 @@ const ActivePill = ({ active }: { active: boolean }) => ( ); export default () => { - const params = useParams() as Params; const history = useHistory(); - const state: State = useLocation().state; + const { state } = useLocation(); + const { id: scheduleId } = useParams(); const id = ServerContext.useStoreState(state => state.server.data!.id); const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); @@ -61,20 +61,20 @@ export default () => { const appendSchedule = ServerContext.useStoreActions(actions => actions.schedules.appendSchedule); useEffect(() => { - if (schedule?.id === Number(params.id)) { + if (schedule?.id === Number(scheduleId)) { setIsLoading(false); return; } clearFlashes('schedules'); - getServerSchedule(uuid, Number(params.id)) + getServerSchedule(uuid, Number(scheduleId)) .then(schedule => appendSchedule(schedule)) .catch(error => { console.error(error); clearAndAddHttpError({ error, key: 'schedules' }); }) .then(() => setIsLoading(false)); - }, [ params ]); + }, [ scheduleId ]); const toggleEditModal = useCallback(() => { setShowEditModal(s => !s);