Skip to main content
1y ago

Manually call cleanup in React?

Hi there! Do I need to manually call rive.cleanup when a component dismounts in React? ie

const RiveComponent: React.FC = () => {
  const { rive, RiveComponent } = useRive({
    src: RiveFile,
    autoplay: true,
  })

  useEffect(() => {
    return () => rive?.cleanup()
  }, [])

  return <RiveComponent />
};

Or are the resources cleaned up automagically?