
Security News
Potemkin Understanding in LLMs: New Study Reveals Flaws in AI Benchmarks
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
babel-react-defaultprops
Advanced tools
A babel plugin that extracts es6 default parameters and append it to the component property named __defaultProps
.
npm install --save-dev babel-react-defaultprops
yarn add -D babel-react-defaultprops
Add the plugin to the Babel configuration:
babel.config.js
module.exports = {
plugins: ['module:babel-react-defaultprops'],
};
Before:
export function FunctionComponent({ bar, foo = 'func' }) {
return <div>{bar + foo}</div>;
}
After:
function FunctionComponent(_ref) {
var bar = _ref.bar,
_ref$foo = _ref.foo,
foo = _ref$foo === void 0 ? 'func' : _ref$foo;
return _react['default'].createElement('div', null, bar + foo);
}
FunctionComponent.__defaultProps = {
foo: 'func',
};
Or with defaults in function body:
Before:
export const VariableComponent = (props) => {
const { bar, foo = 'variable' } = props;
return <div>{bar + foo}</div>;
};
After:
var VariableComponent = function VariableComponent(props) {
var bar = props.bar,
_props$foo2 = props.foo,
foo = _props$foo2 === void 0 ? 'variable' : _props$foo2;
return _react['default'].createElement('div', null, bar + foo);
};
VariableComponent.__defaultProps = {
foo: 'variable',
};
For more example look into the test folder.
If using typescript ad following to theglobal.d.ts
file:
declare module 'react' {
export interface FunctionComponent<P = unknown> {
__defaultProps?: Partial<P>;
}
}
export {};
Node that the default props with the locale variable as a value in the function body will not be included.
FAQs
A plugin to extract es6 default parameters
The npm package babel-react-defaultprops receives a total of 5 weekly downloads. As such, babel-react-defaultprops popularity was classified as not popular.
We found that babel-react-defaultprops demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.