MCPcopy
hub / github.com/TanStack/router / Component

Function Component

packages/solid-router/tests/optional-path-params.test.tsx:596–638  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

useNavigateFunction · 0.90
navigateFunction · 0.50

Tested by

no test coverage detected