()
| 594 | }) |
| 595 | |
| 596 | function Component() { |
| 597 | const navigate = useNavigate() |
| 598 | const params = postsRoute.useParams() |
| 599 | |
| 600 | return ( |
| 601 | <div> |
| 602 | <div data-testid="params">{JSON.stringify(params())}</div> |
| 603 | <button |
| 604 | data-testid="navigate-all" |
| 605 | onClick={() => |
| 606 | navigate({ |
| 607 | to: '/posts/{-$category}/{-$slug}', |
| 608 | params: false, |
| 609 | }) |
| 610 | } |
| 611 | > |
| 612 | All Posts |
| 613 | </button> |
| 614 | <button |
| 615 | data-testid="navigate-tech" |
| 616 | onClick={() => |
| 617 | navigate({ |
| 618 | to: '/posts/{-$category}/{-$slug}', |
| 619 | params: { category: 'tech', slug: undefined }, |
| 620 | }) |
| 621 | } |
| 622 | > |
| 623 | Tech Posts |
| 624 | </button> |
| 625 | <button |
| 626 | data-testid="navigate-specific" |
| 627 | onClick={() => |
| 628 | navigate({ |
| 629 | to: '/posts/{-$category}/{-$slug}', |
| 630 | params: { category: 'tech', slug: 'hello-world' }, |
| 631 | }) |
| 632 | } |
| 633 | > |
| 634 | Specific Post |
| 635 | </button> |
| 636 | </div> |
| 637 | ) |
| 638 | } |
| 639 | // Start at a specific post |
| 640 | window.history.replaceState({}, '', '/posts/tech/hello-world') |
| 641 |
nothing calls this directly
no test coverage detected