A Babel plugin (v4.0.3) that automatically adds an ES2015 import for React to files containing JSX tags. It targets stateless functional components that do not explicitly import React, saving boilerplate. Works with Babel 7+ (v4) and Babel 6 (v3). Released less frequently, with no updates in several years; similar functionality is now partially covered by @babel/preset-react with the 'runtime: automatic' option.
npm install babel-plugin-react-requireVerified import paths — ran on the pinned version, not inferred.
Configures Babel to auto-import React in files with JSX.
Use @babel/preset-react with { "runtime": "automatic" } instead.Order plugins: ["react-require", "transform-es2015-modules-commonjs"]
Manually import named exports: import { useState } from 'react';npm install babel-plugin-react-require --save-dev
Add @babel/preset-react to your Babel config: { "presets": ["@babel/preset-react"] }