Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
create-prop-types
Advanced tools
A lightweight helper library to create custom React prop types.
npm install create-prop-types --save-dev
// ./prop-types/Iterable.js
import createPropType from 'create-prop-types';
import { Iterable } from 'immutable';
const IterablePropType = createPropType({
predicate: propValue => Iterable.isIterable(propValue)
});
export default IterablePropType;
import Iterable from './prop-types/Iterable';
export default class MyComponent extends React.Component {
static propTypes = {
propA: Iterable,
propB: Iterable.isRequired
}
}
predicate: (propValue: any) => boolean
A predicate function to satisfy in order to consider the prop value as valid.
const CustomPropType = createPropType({
predicate: propValue => (propValue !== 'foo')
});
export default CustomPropType;
warnings?: Warnings
Optional custom warning messages.
type Warnings = {
missing?: WarningResolver,
invalid?: WarningResolver
}
type WarningResolver = (propName: string, propValue: any, componentName: string) => string
const CustomPropType = createPropType({
predicate: propValue => ...,
warnings: {
missing: (propName, propValue, componentName) => {
return `Required prop "${propName}" is missing in "${componentName}" component.`;
}
}
});
export default CustomPropType;
This project is licensed under MIT License. See the license file for more details.
FAQs
Create custom React prop types with ease
We found that create-prop-types 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.