babel-plugin-transform-react-pure-to-component
Convert React.PureComponent to React.Component to improve hot reloading.
Last updated 3 years ago by shopify-admin .
MIT · Original npm · Tarball · package.json
$ cnpm install babel-plugin-transform-react-pure-to-component 
SYNC missed versions from official npm registry.

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

Via .babelrc (Recommended)

.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'],
});

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

2 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 10
Dependencies (0)
None
Dev Dependencies (9)

Copyright 2014 - 2017 © taobao.org |