Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-react-pure-to-component

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-react-pure-to-component

Convert React.PureComponent to React.Component to improve hot reloading.

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
98
decreased by-18.33%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-react-pure-to-component

This plugin transforms any class extending React’s PureComponent to extend Component instead. This should only be enabled in development, and only when using hot reloading. Extending Component in all cases in development means that changes to the render method of your component will be run, where PureComponents will opt out via their componentWillUpdate() checks.

Example

In

import React, {PureComponent} from 'react';

class MyComponent extends PureComponent {}

Out

import React, {Component as _Component} from 'react';

class MyComponent extends _Component {}

This plugin also handles cases where you use a namespace import (import * as React from 'react';), default imports with properties (import React from 'react'; class MyComponent extends React.PureComponent {}), and named imports other than React/ PureComponent.

Installation

# yarn
yarn add --dev babel-plugin-pure-to-impure-component

# npm
npm install --save-dev babel-plugin-pure-to-impure-component

Usage

.babelrc

{
  "plugins": ["transform-react-pure-to-component"]
}

Via CLI

babel --plugins transform-react-pure-to-component script.js

Via Node API

require('babel-core').transform('code', {
  plugins: ['transform-react-pure-to-component'],
});

FAQs

Package last updated on 19 Feb 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc