
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
react-props-filter
Advanced tools
Filter miscellaneous props and get props precisely.
$ npm i react-props-filter
import React from 'react';
import PropTypes from 'prop-types';
import filter from 'react-props-filter';
const Hulk = ({ hulkName }) => <p>{`I'm ${hulkName}`}</p>;
Hulk.propTypes = {
hulkName: PropTypes.string.isRequired,
};
const Thor = ({ thorName }) => <p>{`My name is ${thorName}`}</p>;
Thor.propTypes = {
thorName: PropTypes.string.isRequired,
};
const Avengers = filter({
hulk: {
requiredProps: Object.keys(Hulk.propTypes),
},
thor: {
requiredProps: Object.keys(Thor.propTypes),
},
});
const App = () => (
<Avengers
ironManName="Tony Stark"
captainAmericaName="Steve Rogers"
hulkName="Bruce Banner"
thorName="Thor Odinson"
>
{({ hulk, thor, allProps }) => (
<div>
<Hulk {...hulk} />
<Thor {...thor} />
/*
hulk === { hulkName: "Bruce Banner" }
thor === { thorName: "Thor Odinson" }
allProps === {
ironManName: 'Tony Stark',
captainAmericaName: 'Steve Rogers',
hulkName: 'Bruce Banner',
thorName: 'Thor Odinson'
}
*/
</div>
)}
</Avengers>
);
filter: Function(settings) => ComponentThe main method to create Filter component.
ObjectThis contains several groups, and each group will be injected into render props.
Notice: all original props will be stored in the prop named allProps.
For example
const Filter = filter({
groupA: { ...propsGroupSettingsA },
groupB: { ...propsGroupSettingsB },
});
const App = props => (
<Filter { ...props }>
{({ groupA, groupB, allProps }) => (/* ... */) }
</Filter>
)
ObjectDeclare what props does Component need. It has the following keys.
requiredPropsmapPropsoptionsrequiredProps: [String]List which props are required in this group. It's suggested to be Object.keys(Component.propTypes).
mapProps: Function(props) => ObjectA function which lets you map the original props into a single object. All changes will be kept in group scope.
options: Object| Key | Type | Default | Description |
|---|---|---|---|
| DOMProps | Bool | false | Allowed any default DOM props from original props to be included in the group. |
Example for detailed settings
const Filter = filter({
groupA: {
requiredProps: ['propAAA', 'propBBB', 'onClick'],
mapProps: props => ({
...props,
propAAA: props.propA,
propBBB: `${props.propB} !`,
}),
options: {
DOMProps: true,
}
},
});
const App = () => (
<Filter propA="A" propB="B" onClick={console.log}>
{({groupA}) => (/* ... */)
/*
groupA === {
propAAA: 'A',
propBBB: 'B !',
onClick=console.log
}
*/
}
</Filter>
)
MIT © xxhomey19
FAQs
Filter miscellaneous props and get props precisely.
The npm package react-props-filter receives a total of 1 weekly downloads. As such, react-props-filter popularity was classified as not popular.
We found that react-props-filter 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
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.