Skip to content

Commit

Permalink
fix(desk-tool) reset documentType when documentId changes in `use…
Browse files Browse the repository at this point in the history
…DocumentType`
  • Loading branch information
hermanwikner authored and hermanwikner committed Oct 19, 2021
1 parent bf9d007 commit d0468f5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/@sanity/desk-tool/src/utils/resolveDocumentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ export function useDocumentType(
documentType: isResolved ? specifiedType : undefined,
})

// Reset documentType when documentId changes
useEffect(() => {
setDocumentType({
isLoaded: isResolved,
documentType: isResolved ? specifiedType : undefined,
})
}, [documentId, isResolved, specifiedType])

// Load the documentType from Content Lake
useEffect(() => {
if (isResolved) {
return () => {
// intentional noop
}
return undefined
}

const sub = documentStore
Expand Down

3 comments on commit d0468f5

@vercel
Copy link

@vercel vercel bot commented on d0468f5 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

studio-workshop – ./dev/workshop

studio-workshop-git-next.sanity.build
studio-workshop.sanity.build

@vercel
Copy link

@vercel vercel bot commented on d0468f5 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio.sanity.build
test-studio-git-next.sanity.build

@vercel
Copy link

@vercel vercel bot commented on d0468f5 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

perf-studio – ./

perf-studio-git-next.sanity.build
perf-studio.sanity.build

Please sign in to comment.