Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-svg ssr compatibility with nextJs v14 App router #2888

Open
darktell opened this issue Apr 26, 2024 · 0 comments
Open

react-svg ssr compatibility with nextJs v14 App router #2888

darktell opened this issue Apr 26, 2024 · 0 comments

Comments

@darktell
Copy link

It doesn't work as server component in new nextJs App Router. Only with "use client"
I wrote simple component, and get error
image

without turbo get this error

image

const Icon: FC<Props> = ({
  icon,
  svgClassName,
  alt,
  size = 20,
  width,
  height,
  role,
}) => {
  const src = `/images/icons/${icon}.svg`;

  const iconWidth = width ?? size;
  const iconHeight = height ?? size;

  return (
    <>
      <ReactSVG
        role={role || "presentation"}
        src={src}
        width={iconWidth}
        height={iconHeight}
        className={svgClassName}
        // evalScripts="always"
        fallback={() => <span>!</span>}
        title={alt || "icon"}
      />
    </>
  );
};

export default Icon;

honestly I think it can't be a server component because SVGInjector use document.. But just wanna get some thoughts about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant