Skip to content

Conversation

Aarshpatel12
Copy link

Description

This PR fixes issue #9953 by ensuring that the new JSX transform introduced in React 17 continues to work even after ejecting a Create React App project.

Currently, after ejecting, the Babel configuration does not include the necessary plugin for the new JSX runtime, resulting in ReferenceError: React is not defined unless import React is manually added to every file.

Fix

  • Added @babel/preset-react with runtime: 'automatic' option to the Babel configuration in the ejected Webpack setup.
  • Ensured consistent JSX transformation behavior both before and after ejecting.
  • This aligns with React 17+ best practices where explicit import React is no longer required when using the automatic runtime.

Related Issue

Closes #9953

Checklist

  • Ensured React 17+ JSX transform works after eject
  • Verified no breaking changes for projects using older JSX runtime
  • Added Babel preset configuration with automatic runtime

Preview

After this fix:

  • Users can remove import React from 'react' safely in component files
  • No more ReferenceError: React is not defined after ejecting

Let me know if further changes are needed!

@Aarshpatel12
Copy link
Author

Hi maintainers 👋 Just a reminder that this PR addresses #9953 and resolves a breaking behavior in React 17+. All checks are passing and CLA is signed. Kindly review when convenient — thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v4] Bug: React 17, React is not defined after ejecting
2 participants