next-nprogress-bar
Advanced tools
Comparing version 2.0.3 to 2.1.0
@@ -6,4 +6,8 @@ import React from 'react'; | ||
export declare function useRouter(): { | ||
push: (href: string, options?: NavigateOptions) => void; | ||
back(): void; | ||
push: (href: string, options?: NavigateOptions, NProgressOptions?: { | ||
showProgressBar?: boolean; | ||
}) => void; | ||
back: (NProgressOptions?: { | ||
showProgressBar?: boolean; | ||
}) => void; | ||
forward(): void; | ||
@@ -10,0 +14,0 @@ refresh(): void; |
@@ -95,7 +95,20 @@ 'use strict'; | ||
var router = navigation.useRouter(); | ||
function push(href, options) { | ||
var pathname = navigation.usePathname(); | ||
function push(href, options, NProgressOptions) { | ||
if ((NProgressOptions === null || NProgressOptions === void 0 ? void 0 : NProgressOptions.showProgressBar) === false) | ||
return router.push(href, options); | ||
var currentUrl = new URL(pathname, location.href); | ||
var targetUrl = new URL(href, location.href); | ||
if (isSameURL(targetUrl, currentUrl) || href === pathname) | ||
return router.push(href, options); | ||
NProgress.start(); | ||
return router.push(href, options); | ||
} | ||
return __assign(__assign({}, router), { push: push }); | ||
function back(NProgressOptions) { | ||
if ((NProgressOptions === null || NProgressOptions === void 0 ? void 0 : NProgressOptions.showProgressBar) === false) | ||
return router.back(); | ||
NProgress.start(); | ||
return router.back(); | ||
} | ||
return __assign(__assign({}, router), { push: push, back: back }); | ||
} | ||
@@ -102,0 +115,0 @@ |
{ | ||
"name": "next-nprogress-bar", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "NextJS progress bar compatible with new app directory", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -312,3 +312,15 @@ <div align="center"> | ||
// With progress bar | ||
router.push('/about'); | ||
router.back(); | ||
// Without progress bar | ||
router.push( | ||
'/about', | ||
{}, | ||
{ | ||
showProgressBar: false, | ||
}, | ||
); | ||
router.back({ showProgressBar: false }); | ||
``` | ||
@@ -315,0 +327,0 @@ |
Sorry, the diff of this file is not supported yet
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
39479
205
387