Skip to main content
Question

ContentPreview - specify version

  • May 22, 2025
  • 2 replies
  • 3 views

Forum|alt.badge.img

I am using the ContentPreview component in the box-ui-elements package in a React app.

I am passing fileId into the component and would like to specify the fileVersionId to view that specific version.

const fileOptions = { "fileVersionId": "1023764078920" }
<ContentPreview
          hasHeader
          fileId={selectedDocument.boxFileId}
          fileOptions={fileOptions}
          token={token}
          language={language}
          messages={messages}
        />

https://github.com/box/box-content-preview lists fileVersionId as a fileOption, but I havent figured out how to use it with the react version.

2 replies

Forum|alt.badge.img

I was close, the answer is 

 const fileOptions = {
        [selectedDocument.boxFileId]: { fileVersionId: version?.boxVersionId },
      };
      render(
        <ContentPreview          
          hasHeader
          fileId={selectedDocument.boxFileId}
          fileOptions={fileOptions}
          token={token}
          language={language}
          messages={messages}
        />,
        container
      );

Forum|alt.badge.img

Thank you for posting the answer to your own questions. 

Cheers