useDocument
A hook for asynchronously working with documents.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
idReference | string | False | The ID reference of the document on format DATA_SOURCE/UUID.Attribute |
depth | number | True | The maximum depth level of nested objects to resolve |
notify | boolean | False | Show a pop-up on failed/successful requests |
Returns
A list containing the document, a boolean representing the loading state, a function to update the document, and an Error, if any.
Usage
Code example:
import { useDocument } from '@data-modelling-tool/core' const { document, loading, updateDocument, error, } = useDocument(dataSourceId, documentId) if (loading) return <div>Loading...</div> if (error) { console.error(error) return <div>Error getting the document</div> } <DisplayDocument document={document} />