# babel-plugin-react-require

> Babel plugin that adds React import declaration if file contains JSX tags.

Latest version **4.0.3** (published 2024-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-react-require
pnpm add babel-plugin-react-require
yarn add babel-plugin-react-require
bun add babel-plugin-react-require
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.3 |
| Published | 2024-07-23 |
| First published | 2015-06-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 156 |
| Author | Vyacheslav Slinko |
| Maintainers | timneutkens, vslinko |
| Keywords | babel, babel-plugin, react, jsx |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-react-require
- Repository: https://github.com/vslinko/babel-plugin-react-require
- Issues: https://github.com/vslinko/babel-plugin-react-require/issues
- npm.io page: https://npm.io/package/babel-plugin-react-require

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 4.0.3 (latest) — 2024-07-23
- 4.0.2 — 2023-11-02
- 4.0.1 — 2023-07-25
- 4.0.0 — 2023-05-17
- 3.1.3 — 2020-01-02
- 3.1.2 — 2020-01-02
- 3.1.1 — 2019-01-28
- 3.1.0 — 2019-01-27
- 3.0.2 — 2019-01-27
- 3.0.1 — 2018-10-01
- 3.0.0 — 2016-10-11
- 2.1.0 — 2015-12-04
- 2.0.0 — 2015-11-17
- 1.0.2 — 2015-06-13
- 1.0.1 — 2015-06-11

## README

# babel-plugin-react-require

Babel plugin that adds React import declaration if file contains JSX tags.

This plugin is only about stateless components that doesn't extends `React.Component`.
If you want to use any other React functions then you should import their by yourself.

## Example

Your `component.js` that contains this code:

```js
export default function Component() {
  return (
    <div />
  );
}
```

will be transpiled into something like this:

```js
import React from 'react';

export default function Component() {
  /* this part will be transpiled by babel itself as usual */
  return (
    React.createElement('div')
  );
}
```

## Usage

* Install `babel-plugin-react-require`.

```
npm install babel-plugin-react-require --save-dev
```

* Add `react-require` into `.babelrc`. This plugin should be defined before `transform-es2015-modules-commonjs` plugin because it's using ES2015 modules syntax to import `React` into scope.

```json
{
  "plugins": [
    "react-require"
  ]
}
```

---
_Source: https://npm.io/package/babel-plugin-react-require · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
