Skip to content

Commit

Permalink
drop clientHookInServerComponentError
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Mar 13, 2024
1 parent f12c221 commit 183f449
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.

This file was deleted.

8 changes: 0 additions & 8 deletions packages/next/src/client/components/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
PathnameContext,
PathParamsContext,
} from '../../shared/lib/hooks-client-context.shared-runtime'
import { clientHookInServerComponentError } from './client-hook-in-server-component-error'
import { getSegmentValue } from './router-reducer/reducers/get-segment-value'
import { PAGE_SEGMENT_KEY, DEFAULT_SEGMENT_KEY } from '../../shared/lib/segment'
import { ReadonlyURLSearchParams } from './navigation.react-server'
Expand All @@ -36,7 +35,6 @@ import { ReadonlyURLSearchParams } from './navigation.react-server'
* Read more: [Next.js Docs: `useSearchParams`](https://nextjs.org/docs/app/api-reference/functions/use-search-params)
*/
function useSearchParams(): ReadonlyURLSearchParams {
clientHookInServerComponentError('useSearchParams')
const searchParams = useContext(SearchParamsContext)

// In the case where this is `null`, the compat types added in
Expand Down Expand Up @@ -81,7 +79,6 @@ function useSearchParams(): ReadonlyURLSearchParams {
* Read more: [Next.js Docs: `usePathname`](https://nextjs.org/docs/app/api-reference/functions/use-pathname)
*/
function usePathname(): string {
clientHookInServerComponentError('usePathname')
// 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
Expand Down Expand Up @@ -111,7 +108,6 @@ import {
* Read more: [Next.js Docs: `useRouter`](https://nextjs.org/docs/app/api-reference/functions/use-router)
*/
function useRouter(): AppRouterInstance {
clientHookInServerComponentError('useRouter')
const router = useContext(AppRouterContext)
if (router === null) {
throw new Error('invariant expected app router to be mounted')
Expand Down Expand Up @@ -142,8 +138,6 @@ interface Params {
* Read more: [Next.js Docs: `useParams`](https://nextjs.org/docs/app/api-reference/functions/use-params)
*/
function useParams<T extends Params = Params>(): T {
clientHookInServerComponentError('useParams')

return useContext(PathParamsContext) as T
}

Expand Down Expand Up @@ -210,7 +204,6 @@ function getSelectedLayoutSegmentPath(
function useSelectedLayoutSegments(
parallelRouteKey: string = 'children'
): string[] {
clientHookInServerComponentError('useSelectedLayoutSegments')
const context = useContext(LayoutRouterContext)
// @ts-expect-error This only happens in `pages`. Type is overwritten in navigation.d.ts
if (!context) return null
Expand Down Expand Up @@ -239,7 +232,6 @@ function useSelectedLayoutSegments(
function useSelectedLayoutSegment(
parallelRouteKey: string = 'children'
): string | null {
clientHookInServerComponentError('useSelectedLayoutSegment')
const selectedLayoutSegments = useSelectedLayoutSegments(parallelRouteKey)

if (!selectedLayoutSegments || selectedLayoutSegments.length === 0) {
Expand Down

0 comments on commit 183f449

Please sign in to comment.