
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
react-router-query-params
Advanced tools
Set query parameters with a schema for react-router.
npm install --save react-router-query-params
import withQueryParams from 'react-router-query-params';
...
const ExampleComponent = ({
queryParams,
setQueryParams,
}) = (
<div>
<div>
queryParams: {JSON.stringify(queryParams)}
</div>
<button onClick={() => setQueryParams({ example1: 'someQueryParam' })}>
Set query param example
</button>
</div>
);
const ConnectedComponent = withQueryParams({
stripUnknownKeys: false,
keys: {
example1: {
default: 'example-1-default',
validate: value => !!value && value.length > 3,
},
example2: {
default: (value, props) => props.defaultValue,
validate: (value, props) =>
!!value && !props.disallowedValues.includes(value)
}
}
})(ExampleComponent);
queryParams
(object): All current query parameters as key-value pairs in an object.
setQueryParams
(function): Set one or more query parameters.
this.props.setQueryParam({ key1: 'value1', key2: 'value2' })
The library exports withQueryParams
higher order component as default. The HoC takes a configuration object as the first argument, and has the following options:
stripUnknownKeys
(boolean)
true
, removes keys from query parameters that are not configured with keys
keys
(object)
keys: {
example: {
default: 'default-value',
validate: () => true
}
}
Key object is used to create a configuration for the query parameters that are intended to be used. Every key is configured with the following properties:
default
(any): Define the default value for the query parameter. If query parameter valiation fails or it is undefined, the HoC automatically sets the query parameter to this value. Examples:
default: 'example'
: sets 'example' as default valuedefault: (value, props) => props.defaultParam'
: sets defaultParam
from the component props as default valuedefault: undefined
: do not set query parameter at all by defaultvalidate
(function): Validate the query parameter and revert to default value if validation does not pass. Examples:
validate: () => true
: allow any aluevalidate: value => !!value && value.length > 2
: allow any value with more than two charactersvalidate: (value, props) => props.allowedValues.includes(values)
: validate value based on propsMIT
FAQs
Set query parameters with a schema for react-router.
The npm package react-router-query-params receives a total of 246 weekly downloads. As such, react-router-query-params popularity was classified as not popular.
We found that react-router-query-params demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.