Skip to content

🎥 Make videos programmatically with React

`remotion`: Fix showing component location in Studio

JonnyBurgere54aa346ddec
diff --git a/packages/core/src/enable-sequence-stack-traces.ts b/packages/core/src/enable-sequence-stack-traces.ts
index 03357ff786..95fde229a4 100644
--- a/packages/core/src/enable-sequence-stack-traces.ts
+++ b/packages/core/src/enable-sequence-stack-traces.ts
@@ -1,17 +1,17 @@
import React from 'react';
+import JsxRuntime from 'react/jsx-runtime';
import {getRemotionEnvironment} from './get-remotion-environment';
const originalCreateElement = React.createElement;
+const originalJsx = JsxRuntime.jsx;
const componentsToAddStacksTo: unknown[] = [];
-// Gets called when a new component is added,
-// also when the Studio is mounted
-export const enableSequenceStackTraces = () => {
- if (!getRemotionEnvironment().isStudio) {
- return;
- }
-
- const proxy = new Proxy(originalCreateElement, {
+const enableProxy = <
+ T extends typeof React.createElement | typeof JsxRuntime.jsx,
+>(
+ api: T,
+): T => {
+ return new Proxy(api, {
apply(target, thisArg, argArray) {
if (componentsToAddStacksTo.includes(argArray[0])) {
const [first, props, ...rest] = argArray;
@@ -26,8 +26,17 @@ export const enableSequenceStackTraces = () => {
return Reflect.apply(target, thisArg, argArray);
},
});
+};
+
+// Gets called when a new component is added,
+// also when the Studio is mounted
+export const enableSequenceStackTraces = () => {
+ if (!getRemotionEnvironment().isStudio) {
+ return;
+ }
- React.createElement = proxy;
+ React.createElement = enableProxy(originalCreateElement);
+ JsxRuntime.jsx = enableProxy(originalJsx);
};
export const addSequenceStackTraces = (component: unknown) => {