mirror of
https://github.com/rive-app/rive-react.git
synced 2026-03-13 08:22:30 +08:00
41 lines
768 B
TypeScript
41 lines
768 B
TypeScript
import { Layout } from '@rive-app/canvas';
|
|
import React, { ComponentProps } from 'react';
|
|
import useRive from '../hooks/useRive';
|
|
|
|
export type RiveProps = {
|
|
src: string;
|
|
artboard?: string;
|
|
animations?: string | string[];
|
|
stateMachines?: string | string[];
|
|
layout?: Layout;
|
|
useOffscreenRenderer?: boolean;
|
|
};
|
|
|
|
const Rive = ({
|
|
src,
|
|
artboard,
|
|
animations,
|
|
stateMachines,
|
|
layout,
|
|
useOffscreenRenderer = true,
|
|
...rest
|
|
}: RiveProps & ComponentProps<'canvas'>) => {
|
|
const params = {
|
|
src,
|
|
artboard,
|
|
animations,
|
|
layout,
|
|
stateMachines,
|
|
autoplay: true,
|
|
};
|
|
|
|
const options = {
|
|
useOffscreenRenderer,
|
|
};
|
|
|
|
const { RiveComponent } = useRive(params, options);
|
|
return <RiveComponent {...rest} />;
|
|
};
|
|
|
|
export default Rive;
|