File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,9 +131,10 @@ export default function useRive(
131131 let r : Rive | null ;
132132 if ( rive == null ) {
133133 const { useOffscreenRenderer } = options ;
134+ const { onRiveReady, ...restRiveParams } = riveParams ;
134135 r = new Rive ( {
135136 useOffscreenRenderer,
136- ...riveParams ,
137+ ...restRiveParams ,
137138 canvas : canvasElem ,
138139 } ) ;
139140 if ( riveRef . current != null ) {
@@ -143,8 +144,8 @@ export default function useRive(
143144 r . on ( EventType . Load , ( ) => {
144145 isLoaded = true ;
145146
146- if ( options . onLoad ) {
147- options . onLoad ( r ! ) ;
147+ if ( onRiveReady ) {
148+ onRiveReady ( r ! ) ;
148149 }
149150
150151 // Check if the component/canvas is mounted before setting state to avoid setState
Original file line number Diff line number Diff line change 66} from '@rive-app/canvas' ;
77import { ComponentProps , RefCallback } from 'react' ;
88
9- export type UseRiveParameters = Partial < Omit < RiveParameters , 'canvas' > > | null ;
9+ export type UseRiveParameters = Partial < Omit < RiveParameters , 'canvas' > > & {
10+ onRiveReady ?: ( rive : Rive ) => void ;
11+ } | null ;
1012
1113export type UseRiveOptions = {
1214 useDevicePixelRatio : boolean ;
@@ -15,7 +17,6 @@ export type UseRiveOptions = {
1517 useOffscreenRenderer : boolean ;
1618 shouldResizeCanvasToContainer : boolean ;
1719 shouldUseIntersectionObserver ?: boolean ;
18- onLoad ?: ( rive : Rive ) => void ;
1920} ;
2021
2122export type Dimensions = {
You can’t perform that action at this time.
0 commit comments