Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
chore: fix active link in internal links
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-deriv committed Aug 31, 2023
1 parent f280395 commit 67ab3c7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/features/components/atoms/link/internal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useEffect, useState } from 'react'
import { Link } from 'gatsby'
import language_config from '../../../../../i18n-config.js'
import { LinkProps } from '.'
Expand Down Expand Up @@ -66,6 +66,8 @@ const Internal = ({
link_rel,
active_urls,
}: InternalProps) => {
const [is_active, setIsActive] = useState(false)

let rawLocale = 'en'
if (isBrowser()) {
rawLocale = localStorage.getItem('i18n') ?? 'en'
Expand All @@ -77,7 +79,9 @@ const Internal = ({

const to = is_non_localized || is_default ? url.to : `/${path}${url.to}`

const is_active = isActiveLink(url.to, active_urls)
useEffect(() => {
setIsActive(isActiveLink(url.to, active_urls))
}, [active_urls, url.to])

return (
<Link
Expand Down

0 comments on commit 67ab3c7

Please sign in to comment.