react-native-svg-transformer icon indicating copy to clipboard operation
react-native-svg-transformer copied to clipboard

Duplicate __self prop found.

Open acalvino4 opened this issue 2 years ago • 11 comments

After installing react-native-svg-transformer, and following the setup instructions, verbatim, I get the following error in my app:

error: src/App.tsx: Duplicate __self prop found. You are most likely using the deprecated transform-react-jsx-self Babel plugin. Both __source and __self are automatically set when using the automatic runtime. Please remove transform-react-jsx-source and transform-react-jsx-self from your Babel config.

I am using the metro.config.js exactly as it is posted in setup instructions, and by toggling the line babelTransformerPath: require.resolve('react-native-svg-transformer'), I can make the error come and go. (When the line is commented, i get other errors indicating my SVG module is not of the expected type, as one would expect, since it isn't being transformed; I am not concerned about this case.)

acalvino4 avatar Jan 17 '23 21:01 acalvino4

My babel.config.json looks like this:

{
  "presets": ["module:metro-react-native-babel-preset"],
  "plugins": [
    [
      "module-resolver",
      {
        "extensions": [
          ".js",
          ".jsx",
          ".ts",
          ".tsx",
          ".android.js",
          ".android.tsx",
          ".ios.js",
          ".ios.tsx",
          ".svg"
        ],
        "root": ["./src"]
      }
    ],
    "react-native-reanimated/plugin"
  ]
}

acalvino4 avatar Jan 17 '23 21:01 acalvino4

Did you solve this?

I'm facing the same issue, but I don't have react-native-svg-transformer as dependancy. Any update on this please ?

karims10 avatar Jan 29 '24 09:01 karims10

Yeah this is pretty important. Any updates?

GoodestUsername avatar Feb 09 '24 22:02 GoodestUsername

Any update here?

airowe avatar Mar 20 '24 00:03 airowe

Do you have a solution for this error?

CCB-cerivera avatar Apr 04 '24 20:04 CCB-cerivera

I found that pinning all metro versions to be in lockstep with each other resolved this issue for me.

metro-babel-register, metro, metro-react-native-babel-preset, metro-react-native-babel-transformer, `metro-resolver, et al.

airowe avatar Apr 04 '24 20:04 airowe

The problem is that these 2 babel libraries are deprecated for version 73 of RN and version 50 of Expo:

metro-react-native-babel-preset, metro-react-native-babel-transformer

CCB-cerivera avatar Apr 04 '24 20:04 CCB-cerivera

Hello, I just had the same problem, the solution was to remove ['module:@react-native/babel-preset', { "useTransformReactJSXExperimental": true }]] after this you will have to verify some libraries, I recommend deleting the node_modules , .lock after this and compile again.

It should look like this:

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo', 
    plugins: [
      'react-native-reanimated/plugin',
    ],
  };
};

CCB-cerivera avatar Apr 13 '24 00:04 CCB-cerivera

remove module:@react-native/babel-preset and solved

aryan127 avatar Apr 16 '24 11:04 aryan127