next.js/test/e2e/app-dir/navigation/app/use-router/shared-layout/navigate-to-other.js
navigate-to-other.js17 lines506 B
'use client'
import { usePathname } from 'next/navigation'
import { NavigateAndTrackRouterIdentity } from '../navigate'

export function NavigateToOther() {
  const pathname = usePathname()
  const otherPage = pathname.endsWith('/one')
    ? pathname.replace('/one', '/two')
    : pathname.endsWith('/two')
      ? pathname.replace('/two', '/one')
      : (() => {
          throw new Error('Unrecognized pathname: ' + pathname)
        })()

  return <NavigateAndTrackRouterIdentity href={otherPage} />
}
Quest for Codev2.0.0
/
SIGN IN