🎥 Make videos programmatically with React
better error handling and guard for running in node
Jonny Burger213cf19ecd70
diff --git a/packages/core/src/Composition.tsx b/packages/core/src/Composition.tsxindex a2f3b13dde..fb4d4bcf8a 100644--- a/packages/core/src/Composition.tsx+++ b/packages/core/src/Composition.tsx@@ -66,7 +66,7 @@ export const Composition = <T,>({const canUseComposition = useContext(Internals.CanUseRemotionHooks);if (canUseComposition) {- if (window.remotion_isPlayer) {+ if (typeof window !== 'undefined' && window.remotion_isPlayer) {throw new Error('<Composition> was mounted inside the `component` that was passed to the <Player>. See https://remotion.dev/docs/wrong-composition-mount for help.');diff --git a/packages/core/src/use-current-frame.ts b/packages/core/src/use-current-frame.tsindex 837199cced..2458040f5b 100644--- a/packages/core/src/use-current-frame.ts+++ b/packages/core/src/use-current-frame.ts@@ -17,8 +17,14 @@ export const useAbsoluteCurrentFrame = (): number => {export const useCurrentFrame = (): number => {const canUseRemotionHooks = useContext(CanUseRemotionHooks);if (!canUseRemotionHooks) {+ if (typeof window !== 'undefined' && window.remotion_isPlayer) {+ throw new Error(+ `useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`+ );+ }+throw new Error(- `useCurrentFrame() was called outside a component that was registered as a composition.`+ `useCurrentFrame() can only be called inside a component that was registered as a composition. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions`);}