
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
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.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.