Search code examples
exporeact-native-svg

Upgrade Expo react-native-svg dependency version


My Expo project requires the latest version of react-native-svg library to render my SVGs correctly. Currently it's version 9.3.5

From package-json.lock, I see that my current Expo SDK 32 has version 8.0.10 listed.

"dependencies": {
        "react-native-svg": {
          "version": "8.0.10",
          "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-8.0.10.tgz",
          "integrity": "sha512-gsG5GUdvlox67+ohLnq3tZSqiYBmz4M5lKKeUfnJZ8EPrMMS5ZgaVj7Zcccee1VvINS5xQaoenUJdha/GEo34w==",
          "requires": {
            "color": "^2.0.1",
            "lodash": "^4.16.6",
            "pegjs": "^0.10.0"
          }
        }
      }

I have tried just installing latest react-native-svg alongside Expo by using

npm install react-native-svg@9.3.5

However, when running the app I get an error:

Tried to register two views with the same name RNSVGRect

So how can I force Expo to use the latest version? I don't see any react-native-svg dependencies anywhere and changing the package-lock.json directly doesn't seem like a good idea.


Solution

  • Short answer to my question is: you can't. At least not without some ugly hacks that are more trouble than they're worth. The good news is that SDK 33 now comes with "react-native-svg": "~9.4.0" as a dependency and this is almost the latest version as of this writing.