UNPKG

next-query-params

Version:

Convenient state management of query parameters in Next.js apps.

3 lines (2 loc) 799 B
"use strict";var e=require("next/router"),a=require("react"),u=/(?:[\0-"\$->@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+/;exports.NextAdapterPages=function(r){var t=r.children,s=r.shallow,n=void 0===s||s,h=e.useRouter(),o=h.asPath.match(u),F=o?o[0]:h.asPath,c=a.useMemo((function(){return"undefined"!=typeof window?h.isReady?window.location:{search:""}:{search:h.asPath.replace(u,"")}}),[h.asPath,h.isReady]);return t(a.useMemo((function(){function e(e){return function(a){var u=a.hash,r=a.search;e({pathname:h.pathname,search:r,hash:u},{pathname:F,search:r,hash:u},{shallow:n,scroll:!1})}}return{push:e(h.push),replace:e(h.replace),location:c}}),[c,F,h,n]))}; //# sourceMappingURL=NextAdapterPages-b4b86ccd.js.map