Skip to content

Commit abfe333

Browse files
authored
feat(react): enable titleProp option for SVGR in JSX compiler (#412)
1 parent 72dcbc8 commit abfe333

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

examples/vite-react/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function App() {
1313
return (
1414
<div className="App">
1515
<header className="App-header">
16-
<ReactLogo style={{ fontSize: '3em' }} />
16+
<ReactLogo title="React Logo" style={{ fontSize: '3em' }} />
1717
<span dangerouslySetInnerHTML={{ __html: RawReactLogo }}></span>
1818
<p>Hello Vite + React!</p>
1919
<p>

src/core/compilers/jsx.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const JSXCompiler = (async (
1818
{
1919
plugins: ['@svgr/plugin-jsx'],
2020
ref: options.jsx === 'react',
21+
titleProp: options.jsx === 'react',
2122
},
2223
{ componentName: camelize(`${collection}-${icon}`) },
2324
)

types/react.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
declare module 'virtual:icons/*' {
22
import type { ForwardRefExoticComponent, SVGProps } from 'react'
33

4-
const component: ForwardRefExoticComponent<SVGProps<SVGSVGElement>>
4+
const component: ForwardRefExoticComponent<SVGProps<SVGSVGElement> & { title?: string }>
55
export default component
66
}
77
declare module '~icons/*' {
88
import type { ForwardRefExoticComponent, SVGProps } from 'react'
99

10-
const component: ForwardRefExoticComponent<SVGProps<SVGSVGElement>>
10+
const component: ForwardRefExoticComponent<SVGProps<SVGSVGElement> & { title?: string }>
1111
export default component
1212
}

0 commit comments

Comments
 (0)