Skip to content

🎥 Make videos programmatically with React

Fixing typo, the callback should accept an object of type File, not RiveCanvas

Javier Lopez71ebd1a37368
diff --git a/packages/docs/docs/rive/remotionrivecanvas.md b/packages/docs/docs/rive/remotionrivecanvas.md
index e799d600b6..784e717f05 100644
--- a/packages/docs/docs/rive/remotionrivecanvas.md
+++ b/packages/docs/docs/rive/remotionrivecanvas.md
@@ -33,7 +33,7 @@ Either a `string` specifying the animation name, a `number` specifying the anima
### `onLoad?`<AvailableFrom v="4.0.58" />
-A callback function that will be executed when the Rive Runtime is loaded. The argument callback is an object of type `RiveCanvas`
+A callback function that will be executed when the Rive Runtime is loaded. The argument callback is an object of type Rive `File`
## Basic Example
@@ -52,12 +52,12 @@ more information about Text Runs on Rive.
```tsx twoslash
import { RemotionRiveCanvas } from "@remotion/rive";
-import { RiveCanvas } from "@rive-app/canvas-advanced";
+import { File } from "@rive-app/canvas-advanced";
import { useCallback } from "react";
// Make sure to wrap your onLoad handler on `useCallback` to avoid re-rendering this component every single time
-const onLoadHandler = useCallback((rive: RiveCanvas) => {
- const artboard = rive.defaultArtboard();
+const onLoadHandler = useCallback((file: File) => {
+ const artboard = file.defaultArtboard();
const textRun = artboard.textRun("city");
textRun.text = "Tokyo";
}, []);
diff --git a/packages/rive/src/RemotionRiveCanvas.tsx b/packages/rive/src/RemotionRiveCanvas.tsx
index 6be73866ed..7704208f0a 100644
--- a/packages/rive/src/RemotionRiveCanvas.tsx
+++ b/packages/rive/src/RemotionRiveCanvas.tsx
@@ -1,6 +1,7 @@
import type {
Artboard,
CanvasRenderer,
+ File,
LinearAnimationInstance,
RiveCanvas,
} from '@rive-app/canvas-advanced';
@@ -18,7 +19,7 @@ import type {
} from './map-enums.js';
import {mapToAlignment, mapToFit} from './map-enums.js';
-type onLoadCallback = (rive: RiveCanvas) => void;
+type onLoadCallback = (file: File) => void;
interface RiveProps {
src: string;
@@ -101,7 +102,7 @@ export const RemotionRiveCanvas: React.FC<RiveProps> = ({
renderer,
});
if (onLoad) {
- onLoad(riveCanvasInstance);
+ onLoad(file);
}
});
})