Skip to content

🎥 Make videos programmatically with React

fix warning when SSR'ing remotionroot

Jonny Burgera6d7fc0c7d77
diff --git a/packages/core/src/RemotionRoot.tsx b/packages/core/src/RemotionRoot.tsx
index 8a2d788dba..f3c8db39cd 100644
--- a/packages/core/src/RemotionRoot.tsx
+++ b/packages/core/src/RemotionRoot.tsx
@@ -42,8 +42,9 @@ export const RemotionRoot: React.FC<{
const [playbackRate, setPlaybackRate] = useState(1);
const audioAndVideoTags = useRef<PlayableMediaTag[]>([]);
- useLayoutEffect(() => {
- if (typeof window !== 'undefined') {
+ if (typeof window !== 'undefined') {
+ // eslint-disable-next-line react-hooks/rules-of-hooks
+ useLayoutEffect(() => {
window.remotion_setFrame = (f: number) => {
const id = delayRender(`Setting the current frame to ${f}`);
setFrame(f);
@@ -51,8 +52,8 @@ export const RemotionRoot: React.FC<{
};
window.remotion_isPlayer = false;
- }
- }, []);
+ }, []);
+ }
const timelineContextValue = useMemo((): TimelineContextValue => {
return {