mirror of
https://github.com/rive-app/rive-react.git
synced 2025-12-19 01:30:08 +08:00
feat: add onLoad callback to useRive
This commit is contained in:
@@ -142,6 +142,11 @@ export default function useRive(
|
||||
riveRef.current = r;
|
||||
r.on(EventType.Load, () => {
|
||||
isLoaded = true;
|
||||
|
||||
if (options.onLoad) {
|
||||
options.onLoad(r!);
|
||||
}
|
||||
|
||||
// Check if the component/canvas is mounted before setting state to avoid setState
|
||||
// on an unmounted component in some rare cases
|
||||
if (canvasElem) {
|
||||
|
||||
@@ -15,6 +15,7 @@ export type UseRiveOptions = {
|
||||
useOffscreenRenderer: boolean;
|
||||
shouldResizeCanvasToContainer: boolean;
|
||||
shouldUseIntersectionObserver?: boolean;
|
||||
onLoad?: (rive: Rive) => void;
|
||||
};
|
||||
|
||||
export type Dimensions = {
|
||||
|
||||
Reference in New Issue
Block a user