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

Upgrade to support react v19

Open deepakshirbhate opened this issue 10 months ago • 7 comments
trafficstars

Can you please upgrade the libraries to support the latest version of react v19.

deepakshirbhate avatar Jan 16 '25 10:01 deepakshirbhate

-----> Installing dependencies Installing node modules (package.json) npm error code ERESOLVE npm error ERESOLVE unable to resolve dependency tree npm error npm error While resolving: [email protected] npm error Found: [email protected] npm error node_modules/react npm error react@"^19.0.0" from the root project npm error npm error Could not resolve dependency: npm error peer react@"^16.8.0 || ^17.0.0 || ^18.0.0" from [email protected] npm error node_modules/lottie-react npm error lottie-react@"^2.4.0" from the root project

Facing this error

prajapati-mukesh avatar Jan 18 '25 14:01 prajapati-mukesh

As a temporary fix, you can override the dependencies in package.json. This worked for me but you'll need to thoroughly test that all of your animations are still working as expected. Add this to the root level:

"overrides": {
  "lottie-react": {
    "react": "^19.0.0",
    "react-dom": "^19.0.0"
  },
},

jdahdah avatar Jan 22 '25 10:01 jdahdah

https://github.com/Gamote/lottie-react/pull/121 fixes this

jayvdb avatar Jan 22 '25 12:01 jayvdb

Hey there, the lottie-react@^2.4.1 should fix this issue.

Gamote avatar Jan 22 '25 14:01 Gamote

I'm not quite sure with React, but Next.js 15 (latest version) doesn't work with lottie-react at all, even with version 2.4.1. It fails during deployment as below.


Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: document is not defined
    at createTag (/vercel/path0/.next/server/app/page.js:27:173898)

ronaldaug avatar Mar 04 '25 05:03 ronaldaug

@ronaldaug You can use a next/dynamic import to make sure the lottie-react is not server rendered;

import dynamic from 'next/dynamic';

const LottieReact = dynamic(() => import('lottie-react'), {ssr: false});

rvanlaarhoven avatar Mar 07 '25 09:03 rvanlaarhoven

@ronaldaug You can use a next/dynamic import to make sure the lottie-react is not server rendered;

import dynamic from 'next/dynamic';

const LottieReact = dynamic(() => import('lottie-react'), {ssr: false});

This way, when the page is first loaded, it is hidden, but it works

rafaelcardeallodi avatar Mar 09 '25 19:03 rafaelcardeallodi