Fx Document Loader
Type: React component
How to get FxDocumentLoader?
JavaScript
import FxDocumentLoader from 'fontoxml-fx/src/FxDocumentLoader.jsx'
Loads a document. This is used to create document previews for example. A new load will be initiated when the the remoteId changes.
Other
// An example on how the `FxDocumentLoader` can be used.
class DocumentPreview extends Component {
⋮
render() {
return(
<FxDocumentLoader remoteId={selectedItem.id}>
{({ isErrored, error, isLoading, documentId }) => {
if (isErrored) {
return (
<Flex flex="1" paddingSize="l" isScrollContainer>
<FxErroredTemplatedView error={error} />
</Flex>
);
}
if (isLoading) {
return (<StateMessage title="Loading..." visual={<SpinnerIcon />} />);
}
return (<FxNodePreview documentId={documentId} />);
}}
</FxDocumentLoader>
)
}
}
Props
children
(Required)
Type: Function
Implement children as a function. The function should return a react component.
Arguments
Returns
on
Error (Optional)
Type: Function
A callback that is called when the document is errored.
Arguments
Default value
on
Load Is Done (Optional)
Type: Function
A callback that is called when the document has finished loading.
Arguments
Default value
remote
Id (Required)
Type: RemoteDocumentId
The remote id of the the document that needs to be loaded.
referrer
Document Id (Optional)
Type: RemoteDocumentId
The referring document.