mirror of
https://github.com/langgenius/dify.git
synced 2026-07-25 13:38:31 +08:00
28 lines
624 B
TypeScript
28 lines
624 B
TypeScript
'use client'
|
|
|
|
import type { ReactNode } from 'react'
|
|
import type { NextRouteParams } from './atoms'
|
|
import { useHydrateAtoms } from 'jotai/utils'
|
|
import { useParams, usePathname } from '@/next/navigation'
|
|
import { setNextRouteStateAtom } from './atoms'
|
|
|
|
export function NextRouteStateBridge({ children }: { children: ReactNode }) {
|
|
const pathname = usePathname()
|
|
const params = useParams<NextRouteParams>()
|
|
|
|
useHydrateAtoms(
|
|
[
|
|
[
|
|
setNextRouteStateAtom,
|
|
{
|
|
pathname,
|
|
params,
|
|
},
|
|
],
|
|
] as const,
|
|
{ dangerouslyForceHydrate: true },
|
|
)
|
|
|
|
return children
|
|
}
|