This package, `babel-plugin-transform-react-jsx` version 6.24.1, is the legacy plugin for transforming JSX syntax into `React.createElement` calls (or custom pragma calls) within Babel 6 projects. It was the standard way to process JSX for JavaScript applications using Babel's previous major version. This plugin is no longer actively maintained and has been superseded by `@babel/plugin-transform-react-jsx` (and often integrated via `@babel/preset-react`) in Babel 7 and later. Projects currently on Babel 7 or 8 should use the scoped `@babel/plugin-transform-react-jsx` to ensure compatibility with modern React runtimes (classic or automatic) and the latest JavaScript features. This package is relevant only for maintaining older codebases that are specifically pinned to Babel 6.
npm install babel-plugin-transform-react-jsxVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `babel-plugin-transform-react-jsx` in a Babel 6 project to transform JSX syntax, including `pragma` and `useBuiltIns` options, for a simple React component.
Migrate to Babel 7+ and install `@babel/plugin-transform-react-jsx` or `@babel/preset-react` (recommended). Remove `babel-plugin-transform-react-jsx` from your `devDependencies` and Babel config.
To use the `automatic` runtime, you must upgrade to Babel 7+ and use `@babel/plugin-transform-react-jsx` with the `runtime: 'automatic'` option, or use `@babel/preset-react`. For Babel 6, ensure `React` is in scope wherever JSX is used.
Use the `pragma` option in your Babel config for `transform-react-jsx` (e.g., `"pragma": "MyCustomJSXFactory"`) instead of a magic comment if you need a custom JSX factory. Otherwise, rely on the default `React.createElement`.
Do not attempt to use `pragmaFrag` with `babel-plugin-transform-react-jsx`. If you need JSX fragment support, upgrade to Babel 7+ and use `@babel/plugin-transform-react-jsx` with `runtime: 'automatic'` or `runtime: 'classic'` and the `pragmaFrag` option configured.
Ensure `import React from 'react';` is present at the top of any file containing JSX, or that `React` is otherwise accessible in the global scope.
Install `@babel/plugin-transform-react-jsx` (`npm install --save-dev @babel/plugin-transform-react-jsx`) and update your Babel configuration to use `'@babel/transform-react-jsx'` or `@babel/preset-react`.
Review the documentation for `babel-plugin-transform-react-jsx` v6 and ensure `useBuiltIns` is a boolean. If you are targeting modern JavaScript environments where `Object.assign` is natively available, setting it to `true` is usually fine. If the error persists and you are *not* using Babel 6, check the options for `@babel/plugin-transform-react-jsx` which might differ.