react-url-query
Version:
A library for managing state through query parameters in the URL in React. Works well with or without Redux and React Router.
15 lines (13 loc) • 304 B
JavaScript
/**
* Helper function to get only parts of a query. Specify
* which parameters to include.
*/
export default function subquery(query, ...params) {
if (!query) {
return query;
}
return params.reduce((newQuery, param) => {
newQuery[param] = query[param];
return newQuery;
}, {});
}