Skip to content

Skip deprecated jsx-source and jsx-self when using automatic runtime #55459

@ZxPower145

Description

@ZxPower145

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @react-native/babel-preset@0.83.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@react-native/babel-preset/src/configs/main.js b/node_modules/@react-native/babel-preset/src/configs/main.js
index a2f5e1e..9f705e9 100644
--- a/node_modules/@react-native/babel-preset/src/configs/main.js
+++ b/node_modules/@react-native/babel-preset/src/configs/main.js
@@ -188,10 +188,12 @@ const getPreset = (src, options) => {
     firstPartyPlugins.push([require('../plugin-warn-on-deep-imports.js')]);
   }
 
-  if (options && options.dev && !options.useTransformReactJSXExperimental) {
-    extraPlugins.push([require('@babel/plugin-transform-react-jsx-source')]);
-    extraPlugins.push([require('@babel/plugin-transform-react-jsx-self')]);
-  }
+  // Skip deprecated jsx-source and jsx-self when using automatic runtime;
+  // automatic runtime already injects __source and __self (avoids "Duplicate __self prop" error).
+  // if (options && options.dev && !options.useTransformReactJSXExperimental) {
+  //   extraPlugins.push([require('@babel/plugin-transform-react-jsx-source')]);
+  //   extraPlugins.push([require('@babel/plugin-transform-react-jsx-self')]);
+  // }
 
   if (isHermes && enableRegenerator) {
     const hasForOf =

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: InvalidThis issue does not belong here. Applying this label will cause issue to be closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions