Skip to content

🎥 Make videos programmatically with React

Update dynamic-compilation.mdx

Jonny Burger406e99632111
diff --git a/packages/docs/docs/ai/dynamic-compilation.mdx b/packages/docs/docs/ai/dynamic-compilation.mdx
index 4f7ac3d5b6..975219eea3 100644
--- a/packages/docs/docs/ai/dynamic-compilation.mdx
+++ b/packages/docs/docs/ai/dynamic-compilation.mdx
@@ -36,10 +36,7 @@ After transpilation, the result is this string:
Use JavaScript's [`Function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) constructor to turn the string into a real function:
```tsx
-const createComponent = new Function(
- 'React', // Parameter: React will be available inside
- `${transpiled.code}\nreturn MyComponent;`, // Body: define component, then return it
-);
+const createComponent = new Function('React', `${transpiled.code}\nreturn MyComponent;`);
```
This creates a function equivalent to:
@@ -52,7 +49,8 @@ function createComponent(React) {
}
```
-Calling this function and passing the actual React library makes the component available. The component code is wrapped inside, and dependencies (in this case just React) are passed in as arguments.
+Calling this function and passing the actual React library makes the component available.
+The component code is wrapped inside, and dependencies (in this case just React) are passed in as arguments.
```tsx
const Component = createComponent(React);
@@ -106,7 +104,7 @@ const componentBody = match ? match[1].trim() : codeWithoutImports;
const wrappedSource = `const DynamicComponent = () => {\n${componentBody}\n};`;
```
-## Complete Implementation
+## Complete Example
In this example, a React component is compiled and rendered by the [`<Player>`](/docs/player) component.
@@ -226,7 +224,7 @@ export const MyComposition = () => {
</TabItem>
</Tabs>
-## Security Considerations
+## Security
Note that this code runs in the global scope of the browser.
It can access all global variables and functions.