Skip to content

Commit

Permalink
fix: modify the state unsaved issues
Browse files Browse the repository at this point in the history
  • Loading branch information
b3aton committed Jul 21, 2022
1 parent f8dda24 commit 24fa1d0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/storefront/src/pages/registered/RegisteredDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function RegisteredDetail(props: RegisteredDetailProps) {
}
}

setValue('state', stateCode && (stateList.find((state: State) => state.stateCode === stateCode) || stateList.length === 0) ? stateCode : '')
setValue('state', stateCode && countryCode && (stateList.find((state: State) => state.stateCode === stateCode) || stateList.length === 0) ? stateCode : '')

dispatch({
type: 'stateList',
Expand All @@ -104,14 +104,14 @@ export default function RegisteredDetail(props: RegisteredDetailProps) {
useEffect(() => {
const countryValue = getValues('country')
const stateValue = getValues('state')

handleCountryChange(countryValue, stateValue)
}, [])

useEffect(() => {
const subscription = watch(({ country }, { name, type }) => {
const subscription = watch((value, { name, type }) => {
const { country, state } = value
if (name === 'country' && type === 'change') {
handleCountryChange(country)
handleCountryChange(country, state)
}
})
return () => subscription.unsubscribe()
Expand Down

0 comments on commit 24fa1d0

Please sign in to comment.