
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
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
The npm package create-prop-types receives a total of 0 weekly downloads. As such, create-prop-types popularity was classified as not popular.
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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.