SyntaxError? Expression expected #80624
Answered
by
icyJoseph
anonimus007-700
asked this question in
Help
-
Summarythe error:
the code: import React, { useRef } from 'react';
import { useSearchParams } from 'next/navigation'
import ReactDOMServer from 'react-dom/server';
import SunSvg from '@/components/SunSvg';
export async function GET(request: NextRequest) {
const searchParams = useSearchParams()
console.log(searchParams);
let initialCx = 400
let initialCy = 200
const svgString = ReactDOMServer.renderToString(
<SunSvg />
initialCx={initialCx}
initialCy={initialCy}
);
return new NextResponse(svgString, {
headers: {
'Content-Type': 'image/svg+xml',
'Cache-Control': 'public, max-age=31536000, immutable',
},
});
} I'm new to next.js. I want my svg image to be displayed at but when I modify my component: import { SVGProps, forwardRef } from "react"
interface SunSvgProps extends SVGProps<SVGSVGElement> {
initialCx?: number;
initialCy?: number;
}
const SunSvg = forwardRef<SVGSVGElement>(({ initialCx = 696.7, initialCy = 374.9, ...props}, ref) => (
<svg
ref={ref}
... this is part of it I get an error that I can't even describe properly |
Beta Was this translation helpful? Give feedback.
Answered by
icyJoseph
Jun 17, 2025
Replies: 1 comment 2 replies
-
I think this is more or less what you want: const svgString = ReactDOMServer.renderToString(
<SunSvg
initialCx={initialCx}
initialCy={initialCy}
/>
); A few issues/observations here:
I do believe, you either want:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your file is probably
.ts
should be.tsx
I think, after trying out @vercel/og, it only outputs images, but you want SVG, so, I'd try with satori first.
https://og-playground.vercel.app/