Skip to content

Commit

Permalink
fix: remove in sync
Browse files Browse the repository at this point in the history
  • Loading branch information
IanKrieger committed Aug 17, 2023
1 parent 72c5d56 commit 64746b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/components/Creatives/CreativeAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,9 +26,11 @@ interface CreativeAutocompleteProps {
export function CreativeAutocomplete(params: CreativeAutocompleteProps) {
const { setFieldValue } = useFormikContext<CampaignForm>();
const label = params.label;
const [alreadyAdded, setAlreadyAdded] = useState<string[]>(
params.alreadyAssociatedCreativeIds,
);
const [alreadyAdded, setAlreadyAdded] = useState<string[]>([]);

useEffect(() => {
setAlreadyAdded(params.alreadyAssociatedCreativeIds);
}, [params.alreadyAssociatedCreativeIds]);

return (
<Box display="flex" flexDirection="column">
Expand Down
8 changes: 1 addition & 7 deletions src/form/PersistCreativeValues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import _ from "lodash";
import { CreativeInput } from "graphql/types";

export const PersistCreativeValues = () => {
const { values, setValues, dirty, initialStatus } =
useFormikContext<CreativeInput>();
const { values, setValues, dirty } = useFormikContext<CreativeInput>();

// read the values from localStorage on load
useEffect(() => {
Expand All @@ -22,11 +21,6 @@ export const PersistCreativeValues = () => {
}
}, [values, dirty]);

// save the values to localStorage on update
useEffect(() => {
console.log(initialStatus);
}, [initialStatus]);

return null;
};

Expand Down

0 comments on commit 64746b7

Please sign in to comment.