小编Car*_*ugo的帖子

在 Next JS 13 应用程序目录中搜索服务器组件的参数

当使用文件结构 app -> explore -> page.tsx 并使用以下代码获取搜索参数时:

export default function ExplorePage({ searchParams }: { searchParams: { search: string | undefined } }) {
  const { search } = searchParams
Run Code Online (Sandbox Code Playgroud)

我无法运行 npm run build。它给出了这个错误:

Type error: Page "app/explore/page.tsx" does not match the required types of a Next.js Page.
  Invalid configuration:
    The exported page component isn't correctly typed.
        Expected "{ searchParams: { search: any; }; }", got "PageProps".
          Invalid configuration:
            Expected "{ search: any; }", got "Record<string, string | string[]> | undefined". …
Run Code Online (Sandbox Code Playgroud)

reactjs server-side-rendering next.js

14
推荐指数
1
解决办法
2万
查看次数

标签 统计

next.js ×1

reactjs ×1

server-side-rendering ×1