Skip to content

Commit

Permalink
Revert changes in packages/next/src/client/components/navigation.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Jun 3, 2024
1 parent 10ddccc commit cd764ea
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions packages/next/src/client/components/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { ReadonlyURLSearchParams } from './navigation.react-server'
*
* Read more: [Next.js Docs: `useSearchParams`](https://nextjs.org/docs/app/api-reference/functions/use-search-params)
*/
export function useSearchParams(): ReadonlyURLSearchParams {
function useSearchParams(): ReadonlyURLSearchParams {
const searchParams = useContext(SearchParamsContext)

// In the case where this is `null`, the compat types added in
Expand Down Expand Up @@ -78,13 +78,13 @@ export function useSearchParams(): ReadonlyURLSearchParams {
*
* Read more: [Next.js Docs: `usePathname`](https://nextjs.org/docs/app/api-reference/functions/use-pathname)
*/
export function usePathname(): string {
function usePathname(): string {
// In the case where this is `null`, the compat types added in `next-env.d.ts`
// will add a new overload that changes the return type to include `null`.
return useContext(PathnameContext) as string
}

export {
import {
ServerInsertedHTMLContext,
useServerInsertedHTML,
} from '../../shared/lib/server-inserted-html.shared-runtime'
Expand All @@ -107,7 +107,7 @@ export {
*
* Read more: [Next.js Docs: `useRouter`](https://nextjs.org/docs/app/api-reference/functions/use-router)
*/
export function useRouter(): AppRouterInstance {
function useRouter(): AppRouterInstance {
const router = useContext(AppRouterContext)
if (router === null) {
throw new Error('invariant expected app router to be mounted')
Expand Down Expand Up @@ -137,7 +137,7 @@ interface Params {
*
* Read more: [Next.js Docs: `useParams`](https://nextjs.org/docs/app/api-reference/functions/use-params)
*/
export function useParams<T extends Params = Params>(): T {
function useParams<T extends Params = Params>(): T {
return useContext(PathParamsContext) as T
}

Expand Down Expand Up @@ -201,7 +201,7 @@ function getSelectedLayoutSegmentPath(
*
* Read more: [Next.js Docs: `useSelectedLayoutSegments`](https://nextjs.org/docs/app/api-reference/functions/use-selected-layout-segments)
*/
export function useSelectedLayoutSegments(
function useSelectedLayoutSegments(
parallelRouteKey: string = 'children'
): string[] {
const context = useContext(LayoutRouterContext)
Expand Down Expand Up @@ -229,7 +229,7 @@ export function useSelectedLayoutSegments(
*
* Read more: [Next.js Docs: `useSelectedLayoutSegment`](https://nextjs.org/docs/app/api-reference/functions/use-selected-layout-segment)
*/
export function useSelectedLayoutSegment(
function useSelectedLayoutSegment(
parallelRouteKey: string = 'children'
): string | null {
const selectedLayoutSegments = useSelectedLayoutSegments(parallelRouteKey)
Expand All @@ -250,6 +250,18 @@ export function useSelectedLayoutSegment(
: selectedLayoutSegment
}

// Client components APIs
export {
useSearchParams,
usePathname,
useSelectedLayoutSegment,
useSelectedLayoutSegments,
useParams,
useRouter,
useServerInsertedHTML,
ServerInsertedHTMLContext,
}

// Shared components APIs
export {
notFound,
Expand Down

0 comments on commit cd764ea

Please sign in to comment.