
Product
Introducing Immutable Scans
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.
babel-plugin-transform-react-infer-display-name
Advanced tools
A Babel preset for adding `displayName` to React components (descendants of `React.Component` and SFCs).
Add displayName to React components (descendants of React.Component and SFCs).
React.Component ExampleIn
export class StatefulCounter extends React.Component {
constructor(props) {
super(props);
this.state = {
counter: 0,
};
}
render() {
return (
<div>
{this.state.counter}
</div>
);
}
}
Out
export class StatefulCounter extends React.Component {
constructor(props) {
super(props);
this.state = {
counter: 0,
};
}
render() {
return (
<div>
{this.state.counter}
</div>
);
}
}
StatefulCounter.displayName = 'StatefulCounter';
In
export function PureCounter({ counter }) {
return (
<div>
{counter}
</div>
);
}
Out
export function PureCounter({ counter }) {
return (
<div>
{counter}
</div>
);
}
PureCounter.displayName = 'PureCounter';
npm install --save-dev babel-plugin-transform-react-infer-display-name
.babelrc (Recommended).babelrc
{
"plugins": ["transform-react-infer-display-name"]
}
babel --plugins transform-react-infer-display-name script.js
require("babel-core").transform("code", {
plugins: ["transform-react-infer-display-name"]
});
from the root directory
npm install --global mocha
mocha
FAQs
A Babel preset for adding `displayName` to React components (descendants of `React.Component` and SFCs).
We found that babel-plugin-transform-react-infer-display-name demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

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.

Product
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.