Skip to content

Commit

Permalink
feat: add useEffect for ResourceAddress resource state
Browse files Browse the repository at this point in the history
  • Loading branch information
pfferrari committed Nov 24, 2023
1 parent e3431e8 commit 815f26b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PageLayout } from '#ui/composite/PageLayout'
import { type Address } from '@commercelayer/sdk'
import { Note, PencilSimple, Phone } from '@phosphor-icons/react'
import isEmpty from 'lodash/isEmpty'
import { useState } from 'react'
import { useEffect, useState } from 'react'
import { ResourceAddressForm } from './ResourceAddressForm'

export interface ResourceAddressProps {
Expand Down Expand Up @@ -43,6 +43,10 @@ export const ResourceAddress = withSkeletonTemplate<ResourceAddressProps>(

const [address, setAddress] = useState<Address>(resource)

useEffect(() => {
setAddress(resource)
}, [resource.id])

return (
<>
<div className='w-full flex gap-4 space-between'>
Expand Down

0 comments on commit 815f26b

Please sign in to comment.