diff --git a/components/MyProfile/Profile/Edit/Form/Content.tsx b/components/MyProfile/Profile/Edit/Form/Content.tsx index a852cb972..508c3bd4d 100644 --- a/components/MyProfile/Profile/Edit/Form/Content.tsx +++ b/components/MyProfile/Profile/Edit/Form/Content.tsx @@ -27,7 +27,7 @@ export default function FormContent({ control }: EditFormContentProps) { useEffect(() => { setIsPending(pending) - }, [pending]) + }, [pending, setIsPending]) return ( <> diff --git a/components/TempDesignSystem/Form/Country/index.tsx b/components/TempDesignSystem/Form/Country/index.tsx index e30e175d0..aa6be29d6 100644 --- a/components/TempDesignSystem/Form/Country/index.tsx +++ b/components/TempDesignSystem/Form/Country/index.tsx @@ -1,6 +1,6 @@ "use client" import { useController, useFormContext } from "react-hook-form" -import { useEffect, useRef, useState } from "react" +import { useRef } from "react" import { _ } from "@/lib/translation" import { countries } from "./countries" @@ -28,7 +28,6 @@ export default function CountrySelect({ registerOptions, }: CountryProps) { const divRef = useRef(null) - const [divElement, setDivElement] = useState(divRef.current) const { control, setValue } = useFormContext() const { field } = useController({ control, @@ -40,12 +39,6 @@ export default function CountrySelect({ setValue(name, country) } - useEffect(() => { - if (divRef.current) { - setDivElement(divRef.current) - } - }, [divRef.current]) - return (
{countries.map((country, idx) => ( diff --git a/components/TempDesignSystem/Form/Date/Select/index.tsx b/components/TempDesignSystem/Form/Date/Select/index.tsx index fa58473e3..da3ea795a 100644 --- a/components/TempDesignSystem/Form/Date/Select/index.tsx +++ b/components/TempDesignSystem/Form/Date/Select/index.tsx @@ -1,5 +1,5 @@ "use client" -import { useEffect, useRef, useState, type FocusEvent } from "react" +import { useRef } from "react" import { Button, @@ -27,18 +27,11 @@ export default function Select({ value, }: SelectProps) { const divRef = useRef(null) - const [divElement, setDivElement] = useState(divRef.current) function handleOnSelect(key: Key) { onSelect(key, name) } - useEffect(() => { - if (divRef.current) { - setDivElement(divRef.current) - } - }, [divRef.current]) - return (
{items.map((item) => ( diff --git a/components/TempDesignSystem/Form/Phone/index.tsx b/components/TempDesignSystem/Form/Phone/index.tsx index 981939060..beb5ca02f 100644 --- a/components/TempDesignSystem/Form/Phone/index.tsx +++ b/components/TempDesignSystem/Form/Phone/index.tsx @@ -41,21 +41,18 @@ export default function Phone({ rules: registerOptions, }) - const handleCountrySelectForPhone = useCallback( - (country: string) => { - const selectedCountry = getCountry({ - countries: defaultCountries, - field: "iso2", - value: country.toLowerCase(), - }) + const handleCountrySelectForPhone = useCallback((country: string) => { + const selectedCountry = getCountry({ + countries: defaultCountries, + field: "iso2", + value: country.toLowerCase(), + }) - if (selectedCountry) { - phoneRef.current?.setCountry(selectedCountry.iso2) - prevSelectedCountry.current = country.toLowerCase() - } - }, - [phoneRef.current, prevSelectedCountry.current] - ) + if (selectedCountry) { + phoneRef.current?.setCountry(selectedCountry.iso2) + prevSelectedCountry.current = country.toLowerCase() + } + }, []) useEffect(() => { if (countryValue) { @@ -80,7 +77,7 @@ export default function Phone({ handleCountrySelectForPhone(countryValue) } } - }, [countryValue, prevSelectedCountry.current]) + }, [countryValue, field.value, handleCountrySelectForPhone]) return (