Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
react_explicit_prop_declaration
Advanced tools
A ReactJS Mixin to ensure that components explicitly define the properties they allow in their `propTypes`. If a property passed in to the React component is not found in `propTypes` then an error will be thrown.
A ReactJS Mixin to ensure that components explicitly define the properties they
allow in their propTypes
. If a property passed in to the React component is
not found in propTypes
then an error will be thrown.
This is useful for ensuring that all component property interfaces be explicitly defined, which helps when reasoning about what properties a component will accept.
Let's keep our interfaces clean and well documented!
Let's define a very basic React component.
var ExplicitPropDeclarationMixin = require('react_explicit_prop_declaration');
var MyComponent = React.createClass({
mixins: [ExplicitPropDeclarationMixin],
propTypes: {
defined: React.PropTypes.bool
},
render: function () {
// ...
}
});
And now let's render that component with the property we defined in propTypes
:
React.render(<MyComponent defined={true}} />
Cool, so let's do the same, but this time, with a property we did not define in
propTypes
.
React.render(<MyComponent notDefined={false} defined={true}} />
Eeek! An error was thrown telling us what went wrong!
ExplicitPropDeclarationError: The properties "notDefined" were set on the MyComponent, which were not declared in MyComponent.propTypes. Only properties defined in MyComponent.propTypes are allowed to be set on MyComponent.
Looks like, we, as developers need to decide to explicitly define another
propType
we allow on this component, or fix our render
call to not pass in
unexpected properties.
If you would like to contribute code, please do the following:
Please do not iterate the package.json version number – I will do that myself when I publish it to NPM.
FAQs
A ReactJS Mixin to ensure that components explicitly define the properties they allow in their `propTypes`. If a property passed in to the React component is not found in `propTypes` then an error will be thrown.
The npm package react_explicit_prop_declaration receives a total of 3 weekly downloads. As such, react_explicit_prop_declaration popularity was classified as not popular.
We found that react_explicit_prop_declaration 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.