-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useRive
React component lifecycle related init issue
#210
Comments
useRive
React component lifecycle related init issue
FWIW - I have tested out the bog standard import Rive from '@rive-app/react-canvas';
<button onClick={() => setShow(old => !old)}>toggle</button>
{show && (
<Rive
src="https://cdn.rive.app/animations/vehicles.riv"
style={{ width: '400px', height: '400px' }}
/>
)} {/* works as expected when toggling on and off */} |
Hi @glomotion - thanks for reporting, and the repro. We'll take a look, as this is definitely not ideal in React dev! I suspect the issue might be here, where only when the canvas is mounted (aka, If it's feasible for you in the meantime until we give this another pass, as you saw in your second comment, wrapping your logic of using So:
Again, definitely recognize it's not ideal and might be a workaround for now! This also somewhat goes along with #107 too, which is also on the plate. |
@zplata thanks for the suggested work around, did figure something like that might work. |
Hello there! 👋
We are using
useRive
from this library for animations within our DesignSystem, and have noticed a pretty critical React component lifecycle related bug with the useRive hook. 😭I've produced a simple reproduction of this bug in the latest published version of
useRive
from@rive-app/[email protected]
https://stackblitz.com/edit/stackblitz-starters-tc2yg6?file=app%2Fpage.tsx
Essentially, when first revealed (mounted), the Rive animation inits and autoplays as expected. However, once it's unmounted and then re-mounted (in this case using a simple conditional render bool) - the rive animation fails to init and autoplay.
Here is a simple code snippet which demonstrates the issue:
The text was updated successfully, but these errors were encountered: