mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Fix tab default (#5104)
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { useSearchParams } from "react-router-dom"
|
||||
|
||||
export interface UseTabResult {
|
||||
value: string | null
|
||||
value: string
|
||||
set: (value: string) => void
|
||||
}
|
||||
|
||||
export const useTab = (tabKey: string): UseTabResult => {
|
||||
export const useTab = (tabKey: string, defaultValue: string): UseTabResult => {
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const value = searchParams.get(tabKey)
|
||||
const value = searchParams.get(tabKey) ?? defaultValue
|
||||
|
||||
return {
|
||||
value,
|
||||
|
||||
@@ -20,7 +20,7 @@ export const TemplateVersionPage: FC = () => {
|
||||
const [state] = useMachine(templateVersionMachine, {
|
||||
context: { versionName, orgId },
|
||||
})
|
||||
const tab = useTab("file")
|
||||
const tab = useTab("file", "0")
|
||||
const { t } = useTranslation("templateVersionPage")
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user