kristerkari / react-native-svg-transformer

Import SVG files in your React Native project the same way that you would in a Web application.
MIT License
1.61k stars 116 forks source link

Error "Tried to register two views with the same name RNSVGRect" #86

Open Egizas opened 4 years ago

Egizas commented 4 years ago

"Expo": 37.0.0 "react": 16.9.0 "react-native": sdk-37(with expo) "react-native-svg": "11.0.1", "react-native-svg-flagkit": "^0.9.5", "react-native-svg-transformer": "^0.14.3",

I am trying to use local file SVG, it was working fine few months ago with SDK 36. After I upgraded to expo SDK 37, I am getting this error: Requiring module "assets\images\icons\EarthFlag.svg", which threw an exception: Invariant Violation: Tried to register two views with the same name RNSVGRect

This is how I am importing the SVG (as it worked before, there should be nothing wrong with the file itself): import EarthFlag from '../../assets/images/icons/EarthFlag.svg';

and here is my metro.config.js file:

const { getDefaultConfig } = require('metro-config');

module.exports = (async () => {
  const {
    resolver: { sourceExts, assetExts },
  } = await getDefaultConfig();
  return {
    transformer: {
      babelTransformerPath: require.resolve('react-native-svg-transformer'),
    },
    resolver: {
      assetExts: assetExts.filter(ext => ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg'],
    },
  };
})();

Maybe some of you faced the same issue, and could help me.

kristerkari commented 4 years ago

Thanks @Egizas! Is there any possibility for you to create some kind of example project with the problem, so that I could have a look at it? It might just be that some change is required in the config.

dutradotdev commented 1 year ago

facing the same issue here