Niels-IO / next-image-export-optimizer

Use Next.js advanced <Image/> component with the static export functionality. Optimizes all static images in an additional step after the Next.js static export.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support server components

fazpu opened this issue · comments

Hi!

I tried to use the package for the first time with "next": "13.3.1" and "next-image-export-optimizer": "1.6.1" with the app routing logic and its server components.

I'm getting this:

You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.

   ,-[/Users/jiripuc/code/moje/friclegal/client/node_modules/next-image-export-optimizer/dist/ExportedImage.js:1:1]
 1 | import React, { forwardRef, useMemo, useState } from "react";
   :                                      ^^^^^^^^
 2 | import Image from "next/image";
 3 | const splitFilePath = ({ filePath }) => {
 4 |     const filenameWithExtension = filePath.split("\\").pop()?.split("/").pop() || "";
   `----

To the best of my knowledge, the next Image work fine for the server components. Please, could next-image-export-optimizer be updated so that it also works inside the server components?

Thank you for this project!

commented

HI @fazpu,

I am using useClient in the component to keep track of error states and the blur logic. I don't think I can get rid of that. In PR #142 I am adding the useClient directive so that the error will go away.