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

babel-plugin-transform-react-remove-display-name

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-remove-display-name

Make React component `displayName` property available only in none production environment during the build

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-transform-react-remove-display-name

Make React component displayName property available only in none production environment during the build :sparkles:

CI npm

Installation

$ npm install --save-dev babel-plugin-transform-react-remove-display-name
// or
$ yarn add --dev babel-plugin-transform-react-remove-display-name

This plugin is for Babel 7

Story

This plugin was originally created for Semantic UI React package. It wraps each React component displayName property with an if statement which makes sure it will be available only in none production environment.

Example transform

In

const Baz = (props) => (
  <div {...props} />
)

Baz.displayName = "Baz"

Out

const Baz = (props) => (
  <div {...props} />
)

if(process.env.NODE_ENV !== 'production') {
  Baz.displayName = "Baz"
}

Usage

.babelrc

{
  "plugins": ["transform-react-remove-display-name"]
}

Via CLI

$ babel --plugins transform-react-remove-display-name script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-react-remove-display-name"]
});

Inspiration

This plugin is inspired by:

  1. babel-plugin-transform-react-remove-prop-types
  2. babel-plugin-transform-react-handled-props

License

MIT

Keywords

FAQs

Package last updated on 10 May 2023

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