Skip to content

Commit

Permalink
fix: prevent loop error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Feb 7, 2024
1 parent 690a373 commit 7c83467
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {
KeyboardEvent,
SetStateAction,
useEffect,
useRef,
useState,
} from 'react'
import { FieldValues, useForm } from 'react-hook-form'
import { useB3Lang } from '@b3/lang'
import styled from '@emotion/styled'
import { Box, Divider, TextField, Typography } from '@mui/material'
import isEqual from 'lodash-es/isEqual'

import { B3CustomForm, B3Dialog, B3Sping } from '@/components'
import { PRODUCT_DEFAULT_IMAGE } from '@/constants'
Expand Down Expand Up @@ -295,6 +297,7 @@ export default function ChooseOptionsDialog(props: ChooseOptionsDialogProps) {
})

const formValues = watch()
const cache = useRef(formValues)

const getProductVariantId = async (
value: CustomFieldItems,
Expand Down Expand Up @@ -374,6 +377,12 @@ export default function ChooseOptionsDialog(props: ChooseOptionsDialogProps) {
}

useEffect(() => {
if (cache?.current && isEqual(cache?.current, formValues)) {
return
}

cache.current = formValues

if (
Object.keys(formValues).length &&
formFields.length &&
Expand Down

0 comments on commit 7c83467

Please sign in to comment.