use-query-params
Advanced tools
Comparing version 2.1.2 to 2.2.0
@@ -31,4 +31,6 @@ "use strict"; | ||
}) => { | ||
var _a; | ||
const { navigator } = (0, import_react.useContext)(import_react_router_dom.UNSAFE_NavigationContext); | ||
const navigate = (0, import_react_router_dom.useNavigate)(); | ||
const router = (_a = (0, import_react.useContext)(import_react_router_dom.UNSAFE_DataRouterContext)) == null ? void 0 : _a.router; | ||
const location = (0, import_react_router_dom.useLocation)(); | ||
@@ -49,4 +51,4 @@ const adapter = { | ||
get location() { | ||
var _a; | ||
return (_a = navigator == null ? void 0 : navigator.location) != null ? _a : location; | ||
var _a2, _b, _c; | ||
return (_c = (_b = (_a2 = router == null ? void 0 : router.state) == null ? void 0 : _a2.location) != null ? _b : navigator == null ? void 0 : navigator.location) != null ? _c : location; | ||
} | ||
@@ -53,0 +55,0 @@ }; |
import { useContext } from "react"; | ||
import { UNSAFE_NavigationContext, useNavigate, useLocation } from "react-router-dom"; | ||
import { | ||
UNSAFE_NavigationContext, | ||
useNavigate, | ||
useLocation, | ||
UNSAFE_DataRouterContext | ||
} from "react-router-dom"; | ||
const ReactRouter6Adapter = ({ | ||
children | ||
}) => { | ||
var _a; | ||
const { navigator } = useContext(UNSAFE_NavigationContext); | ||
const navigate = useNavigate(); | ||
const router = (_a = useContext(UNSAFE_DataRouterContext)) == null ? void 0 : _a.router; | ||
const location = useLocation(); | ||
@@ -23,4 +30,4 @@ const adapter = { | ||
get location() { | ||
var _a; | ||
return (_a = navigator == null ? void 0 : navigator.location) != null ? _a : location; | ||
var _a2, _b, _c; | ||
return (_c = (_b = (_a2 = router == null ? void 0 : router.state) == null ? void 0 : _a2.location) != null ? _b : navigator == null ? void 0 : navigator.location) != null ? _c : location; | ||
} | ||
@@ -27,0 +34,0 @@ }; |
{ | ||
"name": "use-query-params", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "React Hook for managing state in URL query parameters with easy serialization.", | ||
@@ -66,5 +66,5 @@ "main": "./index.cjs.js", | ||
"react-router-5": "npm:react-router@^5.3.3", | ||
"react-router-6": "npm:react-router@^6.3.0", | ||
"react-router-6": "npm:react-router@^6.8.1", | ||
"react-router-dom-5": "npm:react-router-dom@^5.3.3", | ||
"react-router-dom-6": "npm:react-router-dom@^6.3.0" | ||
"react-router-dom-6": "npm:react-router-dom@^6.8.1" | ||
}, | ||
@@ -93,4 +93,4 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "eef4610254dbe87d29fac4f8f0c35fceba99c0c3", | ||
"gitHead": "e4923cc9038f1448fed71465f6087d6fbd59b711", | ||
"types": "./index.d.ts" | ||
} |
{ | ||
"name": "use-query-params", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "React Hook for managing state in URL query parameters with easy serialization.", | ||
@@ -66,5 +66,5 @@ "main": "./dist/index.cjs.js", | ||
"react-router-5": "npm:react-router@^5.3.3", | ||
"react-router-6": "npm:react-router@^6.3.0", | ||
"react-router-6": "npm:react-router@^6.8.1", | ||
"react-router-dom-5": "npm:react-router-dom@^5.3.3", | ||
"react-router-dom-6": "npm:react-router-dom@^6.3.0" | ||
"react-router-dom-6": "npm:react-router-dom@^6.8.1" | ||
}, | ||
@@ -93,3 +93,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "eef4610254dbe87d29fac4f8f0c35fceba99c0c3" | ||
"gitHead": "e4923cc9038f1448fed71465f6087d6fbd59b711" | ||
} |
@@ -6,1 +6,22 @@ // jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { fetch, Request, Response } from '@remix-run/web-fetch'; | ||
// https://stackoverflow.com/a/74501698/14056107 | ||
// prevent Request not being defined in Vitest | ||
if (!globalThis.fetch) { | ||
// Built-in lib.dom.d.ts expects `fetch(Request | string, ...)` but the web | ||
// fetch API allows a URL so @remix-run/web-fetch defines | ||
// `fetch(string | URL | Request, ...)` | ||
// @ts-expect-error | ||
globalThis.fetch = fetch; | ||
} | ||
if (!globalThis.Request) { | ||
// Same as above, lib.dom.d.ts doesn't allow a URL to the Request constructor | ||
// @ts-expect-error | ||
globalThis.Request = Request; | ||
} | ||
if (!globalThis.Response) { | ||
// web-std/fetch Response does not currently implement Response.error() | ||
// @ts-expect-error | ||
globalThis.Response = Response; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
292459
4840