Lazy load OpenSheetMusicDisplay
This commit is contained in:
1
packages/frontend/src/opensheetmusicdisplay.ts
Normal file
1
packages/frontend/src/opensheetmusicdisplay.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { OpenSheetMusicDisplay as default } from "opensheetmusicdisplay";
|
||||
@@ -1,13 +1,15 @@
|
||||
import { AttachmentId, PieceId } from "common";
|
||||
import { OpenSheetMusicDisplay } from "opensheetmusicdisplay";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { lazy, useEffect, useRef } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { client } from "../client";
|
||||
import { useLoading } from "../loading";
|
||||
|
||||
// TODO: Lazy load `opensheetmusicdisplay` (don't bundle into main script).
|
||||
export const Attachment = lazy(async () => {
|
||||
|
||||
export function Attachment() {
|
||||
const { default: OpenSheetMusicDisplay } = await import("../opensheetmusicdisplay.ts");
|
||||
|
||||
return {
|
||||
default: function Attachment() {
|
||||
|
||||
const params = useParams();
|
||||
const pieceId = PieceId(params.pieceId!);
|
||||
@@ -59,4 +61,6 @@ export function Attachment() {
|
||||
}
|
||||
|
||||
return <div ref={containerRef} className="w-full h-full overflow-scroll sheet-music-display" />;
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user