How to use the react-inlinesvg with React Server Component #199
-
Describe the bug More context - If I use the Icon component on server side, then package throws an error (see below error logs). But if I add 'use client' at the top then error will resolve. Expected behavior Link to repl or repo (highly encouraged) Error logs error - TypeError: Class extends value undefined is not a constructor or null
at eval (webpack-internal:///(sc_server)/./node_modules/react-inlinesvg/lib/index.js:14:58)
at eval (webpack-internal:///(sc_server)/./node_modules/react-inlinesvg/lib/index.js:88:5)
at eval (webpack-internal:///(sc_server)/./node_modules/react-inlinesvg/lib/index.js:459:2)
at Object.(sc_server)/./node_modules/react-inlinesvg/lib/index.js (/Users/ganesh/Code/Things/pain/.next/server/app/page.js:480:1)
at __webpack_require__ (/Users/ganesh/Code/Things/pain/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///(sc_server)/./app/components/logo.tsx:6:73)
at Object.(sc_server)/./app/components/logo.tsx (/Users/ganesh/Code/Things/pain/.next/server/app/page.js:260:1)
at __webpack_require__ (/Users/ganesh/Code/Things/pain/.next/server/webpack-runtime.js:33:42)
at eval (webpack-internal:///(sc_server)/./app/layout.tsx:9:74)
at Object.(sc_server)/./app/layout.tsx (/Users/ganesh/Code/Things/pain/.next/server/app/page.js:271:1) {
type: 'TypeError',
page: '/'
}
null Versions "next": "13.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-inlinesvg": "^3.0.1" |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @gnasamx |
Beta Was this translation helpful? Give feedback.
Hey @gnasamx
This library uses the DOMParser API to parse the SVG so that it won't work on node.js