Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Fix current composition flicker

Jonny Burger24ab95582bcd
diff --git a/packages/studio/src/components/CompositionSelector.tsx b/packages/studio/src/components/CompositionSelector.tsx
index 1f651baa9c..d1151ec16e 100644
--- a/packages/studio/src/components/CompositionSelector.tsx
+++ b/packages/studio/src/components/CompositionSelector.tsx
@@ -116,17 +116,12 @@ export const CompositionSelector: React.FC = () => {
return createFolderTree(compositions, folders, foldersExpanded);
}, [compositions, folders, foldersExpanded]);
- const showCurrentComposition =
- canvasContent && canvasContent.type === 'composition';
-
const list: React.CSSProperties = useMemo(() => {
return {
- height: showCurrentComposition
- ? `calc(100% - ${CURRENT_COMPOSITION_HEIGHT}px)`
- : '100%',
+ height: `calc(100% - ${CURRENT_COMPOSITION_HEIGHT}px)`,
overflowY: 'auto',
};
- }, [showCurrentComposition]);
+ }, []);
const toggleFolder = useCallback(
(folderName: string, parentName: string | null) => {
@@ -140,7 +135,7 @@ export const CompositionSelector: React.FC = () => {
return (
<div style={container}>
- {showCurrentComposition ? <CurrentComposition /> : null}
+ <CurrentComposition />
<div className="__remotion-vertical-scrollbar" style={list}>
{items.map((c) => {
return (
@@ -148,7 +143,9 @@ export const CompositionSelector: React.FC = () => {
key={c.key + c.type}
level={0}
currentComposition={
- showCurrentComposition ? canvasContent.compositionId : null
+ canvasContent && canvasContent.type === 'composition'
+ ? canvasContent.compositionId
+ : null
}
selectComposition={selectComposition}
toggleFolder={toggleFolder}
diff --git a/packages/studio/src/components/CurrentComposition.tsx b/packages/studio/src/components/CurrentComposition.tsx
index 0baf1f420d..c6e61782dd 100644
--- a/packages/studio/src/components/CurrentComposition.tsx
+++ b/packages/studio/src/components/CurrentComposition.tsx
@@ -41,28 +41,26 @@ const row: React.CSSProperties = {
export const CurrentComposition = () => {
const video = Internals.useVideo();
- if (!video) {
- return <div style={container} />;
- }
-
return (
<div style={container}>
- <div style={row}>
- <div>
- <div style={title}>{video.id}</div>
- <div style={subtitle}>
- {video.width}x{video.height}
- {isCompositionStill(video) ? null : `, ${video.fps} FPS`}
- </div>
- {isCompositionStill(video) ? (
- <div style={subtitle}>Still</div>
- ) : (
+ {video ? (
+ <div style={row}>
+ <div>
+ <div style={title}>{video.id}</div>
<div style={subtitle}>
- Duration {renderFrame(video.durationInFrames, video.fps)}
+ {video.width}x{video.height}
+ {isCompositionStill(video) ? null : `, ${video.fps} FPS`}
</div>
- )}
+ {isCompositionStill(video) ? (
+ <div style={subtitle}>Still</div>
+ ) : (
+ <div style={subtitle}>
+ Duration {renderFrame(video.durationInFrames, video.fps)}
+ </div>
+ )}
+ </div>
</div>
- </div>
+ ) : null}
</div>
);
};