Skip to content

Commit

Permalink
fix(form): wait for background fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
soofstad committed May 31, 2024
1 parent 3865373 commit d448ea5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 6 additions & 5 deletions packages/dm-core-plugins/src/form/FormPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
import { Form } from './components/Form'

export const FormPlugin = (props: IUIPlugin) => {
const { document, isLoading, updateDocument, error } = useDocument<any>(
props.idReference,
0
)
if (isLoading) return <Loading />
const { document, isLoading, updateDocument, error, isFetching } =
useDocument<any>(props.idReference, 0)

// react-hook-form is unable to rerender when the document is updated.
// This means that the form will not benefit from react-query caching.
if (isLoading || isFetching) return <Loading />

if (error) throw new Error(JSON.stringify(error, null, 2))

Expand Down
1 change: 0 additions & 1 deletion packages/dm-core/src/hooks/useDocument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function useDocument<T>(
const { dmssAPI } = useApplication()
const [errorResponse, setErrorResponse] = useState<ErrorResponse | null>(null)
const queryClient = useQueryClient()

const queryKeys = ['documents', idReference, depth]
const documentDepth: number = depth ?? 0
if (documentDepth < 0 || documentDepth > 999)
Expand Down

0 comments on commit d448ea5

Please sign in to comment.