Gathering detailed insights and metrics for parse-prop-types
Gathering detailed insights and metrics for parse-prop-types
Gathering detailed insights and metrics for parse-prop-types
Gathering detailed insights and metrics for parse-prop-types
npm install parse-prop-types
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
69 Stars
30 Commits
5 Forks
2 Watching
15 Branches
2 Contributors
Updated on 27 Apr 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
41.9%
18,775
Compared to previous day
Last week
14.3%
87,167
Compared to previous week
Last month
79%
350,739
Compared to previous month
Last year
20.1%
2,675,218
Compared to previous year
1
21
Parses React prop-types
into a readable object at runtime.
$ npm install --save parse-prop-types
1import React from 'react' 2import PropTypes from 'prop-types' 3import parsePropTypes from 'parse-prop-types' 4 5const MyComponent = ({ name, show }) => ( 6 show ? <div>{name}</div> : null 7) 8 9MyComponent.propTypes = { 10 name: PropTypes.string, 11 show: PropTypes.oneOfType([PropTypes.bool, propTypes.string]).isRequired, 12} 13 14MyComponent.defaultProps = { 15 name: 'Haz', 16} 17 18parsePropTypes(MyComponent)
The returned object is compatible with react-docgen
:
1{ 2 name: { 3 type: { 4 name: 'string', 5 }, 6 required: false, 7 defaultValue: { 8 value: 'Haz', 9 }, 10 }, 11 show: { 12 type: { 13 name: 'oneOfType', 14 value: [ 15 { name: 'bool' }, 16 { name: 'string' }, 17 ], 18 }, 19 required: true, 20 }, 21}
IMPORTANT: To avoid issues reading any component's propTypes, it is recommendable importing this package before defining your components' propTypes or before import any third-party component. Import this package in your entry point file could be a great option.
// index.js (entry point file)
import "parse-prop-types";
react-docgen
?react-docgen
reads file contents in order to find prop types definitions. It has some limitations, such as not allowing computed prop types and, in several situations, not being able to parse file contents correctly.
parse-prop-types
, on the other hand, doesn't deal with file contents. Instead, it parses prop types at runtime by receiving the component object itself.
Parameters
$0
any
$0.propTypes
(optional, default {}
)$0.defaultProps
(optional, default {}
)Returns Object
MIT © Diego Haz
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/15 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
69 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More