diff --git a/packages/dm-core-plugins/src/form/FormPlugin.tsx b/packages/dm-core-plugins/src/form/FormPlugin.tsx index e0b101d4f..f040e449e 100644 --- a/packages/dm-core-plugins/src/form/FormPlugin.tsx +++ b/packages/dm-core-plugins/src/form/FormPlugin.tsx @@ -7,11 +7,12 @@ import { import { Form } from './components/Form' export const FormPlugin = (props: IUIPlugin) => { - const { document, isLoading, updateDocument, error } = useDocument( - props.idReference, - 0 - ) - if (isLoading) return + const { document, isLoading, updateDocument, error, isFetching } = + useDocument(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 if (error) throw new Error(JSON.stringify(error, null, 2)) diff --git a/packages/dm-core/src/hooks/useDocument.tsx b/packages/dm-core/src/hooks/useDocument.tsx index 260261523..2206e09e3 100644 --- a/packages/dm-core/src/hooks/useDocument.tsx +++ b/packages/dm-core/src/hooks/useDocument.tsx @@ -59,7 +59,6 @@ export function useDocument( const { dmssAPI } = useApplication() const [errorResponse, setErrorResponse] = useState(null) const queryClient = useQueryClient() - const queryKeys = ['documents', idReference, depth] const documentDepth: number = depth ?? 0 if (documentDepth < 0 || documentDepth > 999)