FxDocumentLoader

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

  1. children

    (Required)

    Type: Function

    Implement children as a function. The function should return a react component.

    Arguments

    Returns

  2. onError

    (Optional)

    Type: Function

    A callback that is called when the document is errored.

    Arguments

    Default value

  3. onLoadIsDone

    (Optional)

    Type: Function

    A callback that is called when the document has finished loading.

    Arguments

    Default value

  4. remoteId

    (Required)

    The remote id of the the document that needs to be loaded.

  5. referrerDocumentId

    (Optional)

    The referring document.