Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
babel-plugin-transform-react-display-name
Advanced tools
Add displayName to React.createClass calls
The babel-plugin-transform-react-display-name package is a Babel plugin that automatically adds display names to React components. This is particularly useful for debugging purposes, as it makes it easier to identify components in the React Developer Tools.
Automatic Display Name Addition
This feature automatically adds a display name to React components, which helps in identifying the component in debugging tools. The plugin scans for React components and assigns a display name based on the variable or function name.
/* .babelrc configuration */
{
"plugins": ["transform-react-display-name"]
}
/* Example React Component */
const MyComponent = () => <div>Hello World</div>;
/* After transformation */
const MyComponent = () => <div>Hello World</div>;
MyComponent.displayName = "MyComponent";
babel-plugin-add-react-displayname is a Babel plugin that also aims to add display names to React components. It provides similar functionality to babel-plugin-transform-react-display-name, ensuring that components are easily identifiable in debugging tools.
Add displayName to
createReactClass
(andReact.createClass
) calls
In
var foo = React.createClass({}); // React <= 15
var bar = createReactClass({}); // React 16+
Out
var foo = React.createClass({
displayName: "foo"
}); // React <= 15
var bar = createReactClass({
displayName: "bar"
}); // React 16+
npm install --save-dev babel-plugin-transform-react-display-name
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-react-display-name"]
}
babel --plugins transform-react-display-name script.js
require("babel-core").transform("code", {
plugins: ["transform-react-display-name"]
});
FAQs
Add displayName to React.createClass calls
We found that babel-plugin-transform-react-display-name demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.