gilbarbara / react-inlinesvg

An SVG loader component for ReactJS

Home Page:https://codesandbox.io/s/github/gilbarbara/react-inlinesvg/tree/main/demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to use inside of RSC

VladyslavL opened this issue · comments

Describe the bug

The title is pretty straightforward - there is no way to use react-inlinesvg inside the React Server Component.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/optimistic-merkle-gv74gf?file=%2Fapp%2Fpage.tsx%3A10%2C1

Steps to reproduce

  1. Craete Next.js project with App router;
  2. Add ;
  3. Do not add 'use client' to the top of the file;
  4. Got an error:
Server Error
Error: Class extends value undefined is not a constructor or null

This might be caused by a React Class Component being rendered in a Server Component, React Class Components only works in Client Components. Read more: https://nextjs.org/docs/messages/class-component-in-server-component

Expected behavior

It would be great to see the support of RSC in future updates.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

No response

react-inlinesvg version

4.0.6

TypeScript version

ˆ5

Build tool

next.js 13.5.6

Additional context

No response

Hey @VladyslavL

This component is client-only, and just migrating it to functional wouldn't "fix" it. Next would still complain about client-side hooks, such as useState.
It needed the "use client" directive more than anything.

Anyway, I've started migrating it, and your issue sped things up a bit.

Fixed in v4.1.0