File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed
Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ const NavBar = () => {
1414 < button onClick = { ( ) => router . push ( '/button-link#34' ) } > ButtonLink</ button >
1515 < Link href = { '#' } > HashLink</ Link >
1616 < Link href = { '/contact/#44' } > HashLink1</ Link >
17+ < button onClick = { ( ) => router . replace ( '/about' ) } > Replace</ button >
1718 </ div >
1819 ) ;
1920} ;
Original file line number Diff line number Diff line change 11{
22 "name" : " next13-progressbar" ,
3- "version" : " 1.1.1 " ,
3+ "version" : " 1.1.2 " ,
44 "description" : " A ProgressBar for next.js >=13 with app directory " ,
55 "main" : " dist/index.js" ,
66 "types" : " dist/index.d.ts" ,
5454 " dist/**/*.mjs*" ,
5555 " dist/**/*.d*"
5656 ]
57- }
57+ }
Original file line number Diff line number Diff line change @@ -166,5 +166,12 @@ export function useRouter() {
166166 return router . push ( href , options ) ;
167167 }
168168
169- return { ...router , push } ;
169+ function replace ( href : string , options ?: NavigateOptions ) {
170+ const targetUrl = new URL ( href , location . href ) ;
171+ if ( targetUrl . pathname === pathname ) return Promise . resolve ( true ) ;
172+ NProgress . start ( ) ;
173+ return router . replace ( href , options ) ;
174+ }
175+
176+ return { ...router , push, replace } ;
170177}
You can’t perform that action at this time.
0 commit comments