Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
hashmap-prop-type
Advanced tools
The missing hashmap prop type validator for React.
This validator is especially useful when you use redux as hashmaps are recommended to structure your data within you state. To know more about state management see https://redux.js.org/docs/faq/OrganizingState.html#how-do-i-organize-nested-or-duplicate-data-in-my-state
This module depends on module prop-types
Run npm install hashmap-prop-type
or yarn add hashmap-prop-type
import React from 'react';
import PropTypes from 'prop-types';
// import the default function from the package, use require('hashmap-proptype').default for common js
import hashmapPropType from 'hashmap-proptype';
class MyComponent extends React.Component {
static propTypes = {
// type your prop with hashmapPropType. You MUST pass a PropType as argument
myHashmap: hashmapPropType(PropTypes.shape({
id: PropTypes.string.isRequired,
myValue: PropTypes.number.isRequired,
})).isRequired;
};
render() {
const { myHashmap } = this.props;
return (
<div>{Object.keys(myHashmap).map(key => <span key={key}>{myHashmap[key].myValue}</span>}</div>
);
}
}
class App extends React.Component {
render() {
// the hashmap to validate
const myHashmap = {
'ddaf34cd-f31b-471b-ae23-6cb2729b580b': {
id: 'ddaf34cd-f31b-471b-ae23-6cb2729b580b',
myValue: 42,
},
'6298edc8-c679-47fa-b52e-60c032eb744d': {
id: '6298edc8-c679-47fa-b52e-60c032eb744d',
myValue: 1234,
},
};
return <MyComponent myHashmap={myHashmap} />
}
}
FAQs
A custom prop type validator for hash maps
The npm package hashmap-prop-type receives a total of 0 weekly downloads. As such, hashmap-prop-type popularity was classified as not popular.
We found that hashmap-prop-type 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.