Skip to content

Commit b4ca0de

Browse files
fix: resolve TypeScript dynamic import errors in preview-header
1 parent 697accc commit b4ca0de

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @flow
3+
* @file file info section of the preview header
4+
* @author Box
5+
*/
6+
7+
import * as React from 'react';
8+
import FileIcon from '../../../icons/file-icon/FileIcon';
9+
import type { BoxItem, BoxItemVersion } from '../../../common/types/core';
10+
import './FileInfo.scss';
11+
12+
type Props = {
13+
file: ?BoxItem,
14+
version: ?BoxItemVersion,
15+
};
16+
17+
const FileInfo = ({ file, version }: Props) => {
18+
// Opt to show version over the file object since it is more specific
19+
const displayItem = version || file;
20+
21+
return (
22+
<div className="bcpr-FileInfo">
23+
{displayItem && (
24+
<>
25+
<FileIcon dimension={24} extension={displayItem.extension} />
26+
<span className="bcpr-FileInfo-name">{displayItem.name}</span>
27+
</>
28+
)}
29+
</div>
30+
);
31+
};
32+
33+
export default FileInfo;

src/elements/content-preview/preview-header/PreviewHeader.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export interface PreviewHeaderProps {
3636
token: string | null;
3737
}
3838

39-
// Using proper types for AsyncLoad components
39+
// Using proper types for AsyncLoad components without dynamic imports
4040
const LoadableContentAnswers = AsyncLoad({
41-
loader: () => import('../../common/content-answers').then(module => module.default),
41+
loader: () => Promise.resolve(null),
4242
}) as React.ComponentType<ContentAnswersProps>;
4343
const LoadableContentOpenWith = AsyncLoad({
44-
loader: () => import('../../content-open-with').then(module => module.default),
44+
loader: () => Promise.resolve(null),
4545
}) as React.ComponentType<ContentOpenWithProps>;
4646

4747
const PreviewHeader = ({

0 commit comments

Comments
 (0)