MCPcopy Index your code
hub / github.com/TanStack/router / useModal

Function useModal

packages/solid-router/tests/useNavigate.test.tsx:2028–2047  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

2026 })
2027
2028 const useModal = (name: string) => {
2029 const currentOpen = postRoute.useSearch({
2030 select: (search) => search[`_${name}`],
2031 })
2032
2033 const navigate = useNavigate()
2034
2035 const setModal = (open: boolean) => {
2036 navigate({
2037 to: '.',
2038 search: (prev: {}) => ({
2039 ...prev,
2040 [`_${name}`]: open ? true : undefined,
2041 }),
2042 resetScroll: false,
2043 })
2044 }
2045
2046 return [currentOpen, setModal] as const
2047 }
2048
2049 function DetailComponent(props: { id: string }) {
2050 const params = useParams({ strict: false })

Callers 1

DetailComponentFunction · 0.70

Calls 1

useNavigateFunction · 0.90

Tested by

no test coverage detected