From 7c1694089f1f07f6339d53627132b77b4ef94ba5 Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Thu, 17 Aug 2023 17:23:49 -0400 Subject: [PATCH] fix: remove in sync --- src/components/Creatives/CreativeAutocomplete.tsx | 10 ++++++---- src/form/PersistCreativeValues.tsx | 8 +------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/components/Creatives/CreativeAutocomplete.tsx b/src/components/Creatives/CreativeAutocomplete.tsx index 138e4b9fe..0eed9a741 100644 --- a/src/components/Creatives/CreativeAutocomplete.tsx +++ b/src/components/Creatives/CreativeAutocomplete.tsx @@ -14,7 +14,7 @@ import moment from "moment"; import { useFormikContext } from "formik"; import { CampaignForm } from "user/views/adsManager/types"; import _ from "lodash"; -import { useState } from "react"; +import { useEffect, useState } from "react"; interface CreativeAutocompleteProps { label: string; @@ -26,9 +26,11 @@ interface CreativeAutocompleteProps { export function CreativeAutocomplete(params: CreativeAutocompleteProps) { const { setFieldValue } = useFormikContext(); const label = params.label; - const [alreadyAdded, setAlreadyAdded] = useState( - params.alreadyAssociatedCreativeIds, - ); + const [alreadyAdded, setAlreadyAdded] = useState([]); + + useEffect(() => { + setAlreadyAdded(params.alreadyAssociatedCreativeIds); + }, [params.alreadyAssociatedCreativeIds]); return ( diff --git a/src/form/PersistCreativeValues.tsx b/src/form/PersistCreativeValues.tsx index 296bf49ed..b27694672 100644 --- a/src/form/PersistCreativeValues.tsx +++ b/src/form/PersistCreativeValues.tsx @@ -4,8 +4,7 @@ import _ from "lodash"; import { CreativeInput } from "graphql/types"; export const PersistCreativeValues = () => { - const { values, setValues, dirty, initialStatus } = - useFormikContext(); + const { values, setValues, dirty } = useFormikContext(); // read the values from localStorage on load useEffect(() => { @@ -22,11 +21,6 @@ export const PersistCreativeValues = () => { } }, [values, dirty]); - // save the values to localStorage on update - useEffect(() => { - console.log(initialStatus); - }, [initialStatus]); - return null; };