pastoria 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/router.tsx +25 -37
package/package.json
CHANGED
package/templates/router.tsx
CHANGED
|
@@ -477,63 +477,51 @@ function router__evaluateNavigationDirection(nav: NavigationDirection) {
|
|
|
477
477
|
|
|
478
478
|
export function useNavigation() {
|
|
479
479
|
const {setLocation} = useContext(RouterContext);
|
|
480
|
-
const [isPending, startTransition] = useTransition();
|
|
481
480
|
|
|
482
481
|
return useMemo(() => {
|
|
483
482
|
function push(nav: NavigationDirection) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
router__evaluateNavigationDirection(nav),
|
|
488
|
-
'push',
|
|
489
|
-
),
|
|
490
|
-
);
|
|
491
|
-
});
|
|
483
|
+
setLocation(
|
|
484
|
+
RouterLocation.parse(router__evaluateNavigationDirection(nav), 'push'),
|
|
485
|
+
);
|
|
492
486
|
}
|
|
493
487
|
|
|
494
488
|
function replace(nav: NavigationDirection) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
);
|
|
502
|
-
});
|
|
489
|
+
setLocation(
|
|
490
|
+
RouterLocation.parse(
|
|
491
|
+
router__evaluateNavigationDirection(nav),
|
|
492
|
+
'replace',
|
|
493
|
+
),
|
|
494
|
+
);
|
|
503
495
|
}
|
|
504
496
|
|
|
505
497
|
function pushRoute<R extends RouteId>(
|
|
506
498
|
routeId: R,
|
|
507
499
|
params: z.input<RouterConf[R]['schema']>,
|
|
508
500
|
) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
);
|
|
516
|
-
});
|
|
501
|
+
setLocation(
|
|
502
|
+
RouterLocation.parse(
|
|
503
|
+
router__createPathForRoute(routeId, params),
|
|
504
|
+
'push',
|
|
505
|
+
),
|
|
506
|
+
);
|
|
517
507
|
}
|
|
518
508
|
|
|
519
509
|
function replaceRoute<R extends RouteId>(
|
|
520
510
|
routeId: R,
|
|
521
511
|
params: z.input<RouterConf[R]['schema']>,
|
|
522
512
|
) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
);
|
|
533
|
-
});
|
|
513
|
+
setLocation((prevLoc) =>
|
|
514
|
+
RouterLocation.parse(
|
|
515
|
+
router__createPathForRoute(routeId, {
|
|
516
|
+
...prevLoc.params(),
|
|
517
|
+
...params,
|
|
518
|
+
}),
|
|
519
|
+
'replace',
|
|
520
|
+
),
|
|
521
|
+
);
|
|
534
522
|
}
|
|
535
523
|
|
|
536
|
-
return {push, replace, pushRoute, replaceRoute
|
|
524
|
+
return {push, replace, pushRoute, replaceRoute} as const;
|
|
537
525
|
}, [setLocation]);
|
|
538
526
|
}
|
|
539
527
|
|