import { type PropsWithChildren, useLayoutEffect } from 'react'
import { NavigateFunction, useNavigate } from 'react-router'

export let navigate: NavigateFunction

export const SetupNavigation = ({ children }: PropsWithChildren) => {
  const navgation = useNavigate()
  useLayoutEffect(() => {
    navigate = navgation
  }, [])
  return <>{children}</>
}
