New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-filter-by-url

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-filter-by-url - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

13

dist/cjs/hooks/useUrlFilter.js

@@ -5,3 +5,2 @@ "use strict";

const react_1 = require("react");
const react_router_dom_1 = require("react-router-dom");
/**

@@ -15,4 +14,4 @@ *

function useUrlFilter(params, apiUrl) {
const query = useQuery();
const navigate = (0, react_router_dom_1.useNavigate)();
const url = new URL(window.location.href);
const query = url.searchParams;
const [apiQuery, setApiQuery] = (0, react_1.useState)(apiUrl);

@@ -31,3 +30,3 @@ const [queryString, setQueryString] = (0, react_1.useState)('');

setQueryString(query);
navigate(query);
window.history.pushState({}, '', query);
};

@@ -39,3 +38,3 @@ const buildQuery = (params, filter) => {

});
return url;
return url.replace('&', '');
};

@@ -60,6 +59,2 @@ const convertParamsToFilterObject = (params) => {

exports.useUrlFilter = useUrlFilter;
function useQuery() {
const { search } = (0, react_router_dom_1.useLocation)();
return (0, react_1.useMemo)(() => new URLSearchParams(search), [search]);
}
//# sourceMappingURL=useUrlFilter.js.map

@@ -1,3 +0,2 @@

import { useEffect, useMemo, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useEffect, useState } from 'react';
/**

@@ -11,4 +10,4 @@ *

export function useUrlFilter(params, apiUrl) {
const query = useQuery();
const navigate = useNavigate();
const url = new URL(window.location.href);
const query = url.searchParams;
const [apiQuery, setApiQuery] = useState(apiUrl);

@@ -27,3 +26,3 @@ const [queryString, setQueryString] = useState('');

setQueryString(query);
navigate(query);
window.history.pushState({}, '', query);
};

@@ -35,3 +34,3 @@ const buildQuery = (params, filter) => {

});
return url;
return url.replace('&', '');
};

@@ -55,6 +54,2 @@ const convertParamsToFilterObject = (params) => {

}
function useQuery() {
const { search } = useLocation();
return useMemo(() => new URLSearchParams(search), [search]);
}
//# sourceMappingURL=useUrlFilter.js.map

@@ -7,3 +7,3 @@ {

},
"version": "0.1.0",
"version": "0.2.0",
"description": "A React library to update API Url with query parameters by looking at query parameters in the address bar of browser.",

@@ -27,6 +27,4 @@ "main": "dist/cjs/index.js",

"@types/react-dom": "^17.0.11",
"prettier": "2.7.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.1",
"typescript": "^4.5.2"

@@ -36,4 +34,3 @@ },

"react": "^17.0 || ^16.0 || ^18.0",
"react-dom": "^17.0 || ^16.0 || 18.0",
"react-router-dom": "^6.2 || ^6.0 || ^6.2 || ^6.1 || ^6.3"
"react-dom": "^17.0 || ^16.0 || 18.0"
},

@@ -40,0 +37,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc