Open AnweshGangula opened 9 months ago
I tried this out in the Playground and noticed that the resultant TSX doesn't consider titleId
as an optional property. Could this be an issue?
<title id={titleId}>{"Rectangle 5"}</title>
import * as React from "react"
import { SVGProps } from "react"
interface SVGRProps {
title?: string;
titleId?: string;
}
const SvgComponent = ({
title,
titleId,
...props
}: SVGProps<SVGSVGElement> & SVGRProps) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width={48}
height={1}
title="abc"
aria-labelledby={titleId}
{...props}
>
{title === undefined ? (
<title id={titleId}>{"Rectangle 5"}</title>
) : title ? (
<title id={titleId}>{title}</title>
) : null}
<path fill="currentColor" fillRule="evenodd" d="M0 0h48v1H0z" />
</svg>
)
export default SvgComponent
🐛 Bug Report
The documentation says that
But, setting
titleProp: true
in Next.js webpack doesn't add title even if the SVG itself has a title element in it.To Reproduce
Create a Nextjs project and configure SVGR in it
<title>
element in itimport SVG from './../abc.svg?svgr
<ReactSvgImport />
Expected behavior
The resultant SVG in DOM should fallback to the existing title element from the root SVG