function useTabParam
useTabParam<T extends string>(
base: string,
validTabs: Iterable<T>,
defaultTab: T
): [T | null, (
tab: T,
search?: string
) => void]

Returns the tab the path segment after base names, defaultTab on the bare base, or null when the segment names none of validTabs, for the page to answer as not found; and a setter that navigates to a tab in place of the current history entry, the default tab to the bare base, with the query string search, the current one by default. A segment after the tab's, as the profile's /follow/playlists, is the tab's own business.

Type Parameters

T extends string

Parameters

base: string
validTabs: Iterable<T>
defaultTab: T

Return Type

[T | null, (
tab: T,
search?: string
) => void]

Usage

import { useTabParam } from "src/hooks/shared/useTabParam.ts";