🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

babel-plugin-import-react

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-import-react

> A small babel plugin to automatically import React and it's hooks on your components

1.0.4
latest
npm
Version published
Maintainers
1
Created
Source

babel-plugin-import-react

A small babel plugin to automatically import React and it's hooks on your components

Installation

# yarn
yarn add --dev babel-plugin-import-react

# npm
npm i --save-dev babel-plugin-import-react

Usage

Include it on your .babelrc

{
	"plugins": ["import-react"]
}

Now you can write all your components this way (without importing React and it's hooks)

// index.jsx
import { render } from 'react-dom'
import App from './App.jsx'

render(<App />, document.getElementById('app'))
// App.jsx
const App = () => {
	// No need to import the `useState` hook
	const [msg] = useState('Hello World from App!')
	return <h1>{msg}</h1>
}

export default App

FAQs

Package last updated on 10 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts