mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
UseEffect to make sure that window is not undefined
This commit is contained in:
parent
7126d3fecf
commit
a3f075fa4b
1 changed files with 6 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { ReactNode, useEffect, useMemo, useRef } from 'react'
|
||||
import { ReactNode, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { StyledText } from '../../elements/StyledText'
|
||||
import { Box, HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives'
|
||||
import { Button } from '../../elements/Button'
|
||||
|
|
@ -735,11 +735,13 @@ type NavButtonRedirectProps = {
|
|||
}
|
||||
|
||||
function NavRedirectButton(props: NavButtonRedirectProps): JSX.Element {
|
||||
const selected = useMemo(() => {
|
||||
return window.location.pathname.includes(props.redirectLocation)
|
||||
}, [props.redirectLocation])
|
||||
const [selected, setSelected] = useState(false);
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
setSelected(window.location.pathname.includes(props.redirectLocation))
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<HStack
|
||||
alignment="center"
|
||||
|
|
|
|||
Loading…
Reference in a new issue