Skip to content

Commit

Permalink
upd: router replace path
Browse files Browse the repository at this point in the history
  • Loading branch information
nicitaacom committed Jul 14, 2024
1 parent 4becc28 commit 8c1902d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import { useEffect } from "react"

import useDarkMode from "@/store/ui/darkModeStore"
import { useSearchParams } from "next/navigation"
import { usePathname, useRouter, useSearchParams } from "next/navigation"
import { utmSourceAction } from "@/actions/utmSourceAction"

export default function Layout({ children }: { children: React.ReactNode }) {
const darkMode = useDarkMode()
const searchParams = useSearchParams()
const router = useRouter()
const path = usePathname()

useEffect(() => {
const utm_source = searchParams?.get("utm_source")?.trimEnd() ?? ""
Expand All @@ -17,6 +19,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
await utmSourceAction(utm_source)
}
utmSourceFn()
router.replace(path)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchParams])
Expand Down

0 comments on commit 8c1902d

Please sign in to comment.