Skip to content

Commit

Permalink
Merge pull request #4131 from remotion-dev/deny-rsc-export
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger authored Jul 29, 2024
2 parents 69c3df6 + a854f03 commit 0fa7e88
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/core/src/_check-rsc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {createContext} from 'react';

if (typeof createContext !== 'function') {
const err = [
'Remotion requires React.createContext, but it is "undefined".',
'If you are in a React Server Component, turn it into a client component by adding "use client" at the top of the file.',
'',
'Before:',
' import {useCurrentFrame} from "remotion";',
'',
'After:',
' "use client";',
' import {useCurrentFrame} from "remotion";',
];

throw new Error(err.join('\n'));
}
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_check-rsc.js';
import './asset-types.js';
import {Clipper} from './Clipper.js';
import type {Codec} from './codec.js';
Expand Down
17 changes: 17 additions & 0 deletions packages/player/src/_check-rsc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {createContext} from 'react';

if (typeof createContext !== 'function') {
const err = [
'Remotion requires React.createContext, but it is "undefined".',
'If you are in a React Server Component, turn it into a client component by adding "use client" at the top of the file.',
'',
'Before:',
' import {Player} from "@remotion/player";',
'',
'After:',
' "use client";',
' import {Player} from "@remotion/player";',
];

throw new Error(err.join('\n'));
}
1 change: 1 addition & 0 deletions packages/player/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './_check-rsc.js';
import {BufferingIndicator} from './BufferingIndicator.js';
import {calculateCanvasTransformation} from './calculate-scale.js';
import {PlayerEventEmitterContext} from './emitter-context.js';
Expand Down

0 comments on commit 0fa7e88

Please sign in to comment.