diff --git a/src/views/Package/LanguageBar.tsx b/src/views/Package/LanguageBar.tsx index 4edecf94..0593264a 100644 --- a/src/views/Package/LanguageBar.tsx +++ b/src/views/Package/LanguageBar.tsx @@ -1,7 +1,5 @@ import { IconButton, Stack } from "@chakra-ui/react"; import type { FunctionComponent } from "react"; -import { useHistory } from "react-router-dom"; -import { getFullPackageName } from "../../api/package/util"; import { LanguageSupportTooltip } from "../../components/LanguageSupportTooltip"; import { Language, @@ -10,9 +8,7 @@ import { LANGUAGES, } from "../../constants/languages"; import { clickEvent, useAnalytics } from "../../contexts/Analytics"; -import { getPackagePath } from "../../util/url"; import { PACKAGE_ANALYTICS } from "./constants"; -import { usePackageState } from "./PackageState"; export interface LanguageBarProps { targetLanguages: readonly Language[]; @@ -23,10 +19,9 @@ export interface LanguageBarProps { export const LanguageBar: FunctionComponent = ({ targetLanguages, selectedLanguage, + setSelectedLanguage, }) => { const { trackCustomEvent } = useAnalytics(); - const { name, scope, version } = usePackageState(); - const { push } = useHistory(); return ( = ({ name: PACKAGE_ANALYTICS.LANGUAGE.eventName(language), }) ); - // reset to package root since our URL scheme for APIs currently - // differs between languages. - push( - getPackagePath({ - name: getFullPackageName(name, scope), - version, - language, - }) - ); + setSelectedLanguage(language); }; return (