rive-react icon indicating copy to clipboard operation
rive-react copied to clipboard

Loading file error

Open robmi10 opened this issue 3 years ago • 5 comments

Im using next js and when im trying to render my riv file i get this error "Problem loading file; may be corrupt! Screenshot 2022-10-29 at 23 50 46

robmi10 avatar Oct 29 '22 22:10 robmi10

The error message should be clearer here. That rive file most likely may not be discoverable when your app is run.

If you place your rive/ folder in the public/assets/ folder of your NextJS app, you could set src as /assets/rives/pharao.riv and that might work.

zplata avatar Nov 10 '22 15:11 zplata

I just ran into this as well and it seems like a duplicate of https://github.com/rive-app/rive-react/issues/90

ryparker avatar Nov 27 '22 22:11 ryparker

i know its an old stuff, but ive been trying to fix that to work with React/Capacitor since we dont have /public as all the magic is happening on build. for us the fix was:


import { useRive } from '@rive-app/react-canvas';
import React from 'react';

import BouncyBall from '../images/rive/bouncy_ball.riv?url';

import styles from './riveWrapper.module.scss';

export default function RiveWrapper() {
  const { rive, RiveComponent } = useRive({
    src: BouncyBall,
    stateMachines: 'Motion',
    autoplay: false,
  });
  return (
    <div className={styles.riveContainer}>
      <RiveComponent onClick={() => rive && rive.play()} />
    </div>
  );
}

our setup is React/Capacitor/VIte - no additional config in vite or ts required just this ?url suffix

MichalKurzewski avatar Feb 14 '24 13:02 MichalKurzewski

For some reason this solution doesn't work with NextJS, it gives 404 if you import rives like that

i know its an old stuff, but ive been trying to fix that to work with React/Capacitor since we dont have /public as all the magic is happening on build. for us the fix was:


import { useRive } from '@rive-app/react-canvas';
import React from 'react';

import BouncyBall from '../images/rive/bouncy_ball.riv?url';

import styles from './riveWrapper.module.scss';

export default function RiveWrapper() {
  const { rive, RiveComponent } = useRive({
    src: BouncyBall,
    stateMachines: 'Motion',
    autoplay: false,
  });
  return (
    <div className={styles.riveContainer}>
      <RiveComponent onClick={() => rive && rive.play()} />
    </div>
  );
}

our setup is React/Capacitor/VIte - no additional config in vite or ts required just this ?url suffix

I added a rule for webpack to handle this type of files, but it didn't work too.

config.module.rules.push({
      test: /\.riv/,
      loader: 'file-loader',
    })

Maclay74 avatar Oct 10 '24 22:10 Maclay74

On some apps this doesn't work for me too. On few of them also changing the riv extension to SVG (it will still work as animation) fixes that , which is super weird.

MichalKurzewski avatar Oct 11 '24 07:10 MichalKurzewski