WebStorm thinks unused constant getStaticProps and getStaticPaths and default exports

Viewed 638

I am writing a NextJS with getStaticProps & getStaticPaths using WebStorm:

export const getStaticProps: GetStaticProps<Props, Params> = async ({
  params,
}) => {
  const productId = params?.pid;
  console.log("pd:", productId);
  const filePath: string = path.join(
    process.cwd(),
    "data",
    "dummy-backend.json"
  );
  const jsonData: string = await fs.readFile(filePath, "utf8");
  const data: Products = JSON.parse(jsonData);
  const product: Product | undefined = data.products.find(
    (product) => product.id === productId
  );

  return {
    props: {
      loadedProduct: product,
    },
  };
};

export const getStaticPaths: GetStaticPaths<Params> = async () => {
  return {
    paths: [
      { params: { pid: "p1" } },
      { params: { pid: "p2" } },
      { params: { pid: "p3" } },
      { params: { pid: "p4" } },
      { params: { pid: "p5" } },
    ],
    fallback: false,
  };
};

export default ProductDetailPage;

Using yarn build & yarn start, we can pre-render using id in NextJS. Therefore, we believe that NextJS uses getStaticProps & getStaticPaths. Why does WebStorm point this out?

When performing code analysis, WebStorm complains with the following warning:

Unused constant getStaticProps
Unused constant getStaticPaths
Unused default export

Please let me know if you find out anything.

GitHub page: https://github.com/blackraccoon000/nextjs-pre-rendering/blob/pidUsed/pages/%5Bpid%5D.tsx

0 Answers
Related