English 中文(简体)
“TypeError:Cannot读坏(读取)”时,在故事书档案中使用SearchParams
原标题:Getting "TypeError: Cannot read properties of null (reading get )" when using useSearchParams in Storybook file

下面的几节是:

import { useSearchParams } from  next/navigation ;

const searchParams = useSearchParams();
const currentPage = parseInt(searchParams.get( page ) ||   , 10) || 1;

我在《故事书》(stories)中发现这一错误:

类型错误:Cannot读作(读取)

犯罪线是:

const currentPage = parseInt(searchParams.get( page ) ||   , 10) || 1;

阅读官方故事书 我试图这样做:

const meta: Meta<typeof ItemModal> = {
  title:  Example/List ,
  component: ItemModal,
  parameters: {
    nextjs: {
      appDirectory: true,
      navigation: {
        searchParams: {
          page:  1 ,
        },
      },
    },
  },
};

Also this:

navigation: {
  segments: [
    [ page ,  1 ],
  ],
},

而且:

navigation: {
  segments: [[ ?page=1 ]],
},

But I m still getting the same error.

我做了什么错误?

还张贴了

更新:我有<条码>console.log(海切帕拉姆: ,搜索帕拉姆);,返回<条码>。 尽管我做了,该

:是完整的组成部分。

问题回答




相关问题
How to use one react app into another react app?

I have two react apps, parent app and child app. and child app have an hash router. I have build the child app using npm run build, It creates build folder. That build folder moved into inside the ...

how to get selected value in Ant Design

I want to print the selected value, and below is my option list: const vesselName = [ { value: 0 , label: ALBIDDA , }, { value: 1 , label: ALRUMEILA , }, { value: 2 ,...

How to add a <br> tag in reactjs between two strings?

I am using react. I want to add a line break <br> between strings No results and Please try another search term. . I have tried No results.<br>Please try another search term. but ...

热门标签