@@ -90,27 +90,22 @@ export default SvgComponent;"
90
90
exports[`plugin javascript with "ref" and "expandProps" option expands props 1`] = `
91
91
"import * as React from \\"react\\";
92
92
93
- function SvgComponent({
94
- svgRef,
95
- ...props
96
- }) {
93
+ function SvgComponent(props, svgRef) {
97
94
return <svg><g /></svg>;
98
95
}
99
96
100
- const ForwardRef = React.forwardRef((props, ref) => < SvgComponent svgRef={ref} {...props} /> );
97
+ const ForwardRef = React.forwardRef(SvgComponent);
101
98
export default ForwardRef;"
102
99
`;
103
100
104
101
exports[`plugin javascript with "ref" option adds ForwardRef component 1`] = `
105
102
"import * as React from \\"react\\";
106
103
107
- function SvgComponent({
108
- svgRef
109
- }) {
104
+ function SvgComponent(props, svgRef) {
110
105
return <svg><g /></svg>;
111
106
}
112
107
113
- const ForwardRef = React.forwardRef((props, ref) => < SvgComponent svgRef={ref} {...props} /> );
108
+ const ForwardRef = React.forwardRef(SvgComponent);
114
109
export default ForwardRef;"
115
110
`;
116
111
@@ -127,18 +122,30 @@ function SvgComponent({
127
122
export default SvgComponent;"
128
123
`;
129
124
130
- exports[`plugin javascript with both "memo " and "ref" option wrap component in "React.memo" and "React.forwardRef" 1`] = `
125
+ exports[`plugin javascript with "titleProp " and "expandProps" adds "titleProp", "titleId" props and expands props 1`] = `
131
126
"import * as React from \\"react\\";
132
127
133
128
function SvgComponent({
134
- svgRef
129
+ title,
130
+ titleId,
131
+ ...props
135
132
}) {
136
133
return <svg><g /></svg>;
137
134
}
138
135
139
- const MemoSvgComponent = React.memo(SvgComponent);
140
- const ForwardRef = React.forwardRef((props, ref) => <MemoSvgComponent svgRef={ref} {...props} />);
141
- export default ForwardRef;"
136
+ export default SvgComponent;"
137
+ `;
138
+
139
+ exports[`plugin javascript with both "memo" and "ref" option wrap component in "React.memo" and "React.forwardRef" 1`] = `
140
+ "import * as React from \\"react\\";
141
+
142
+ function SvgComponent(props, svgRef) {
143
+ return <svg><g /></svg>;
144
+ }
145
+
146
+ const ForwardRef = React.forwardRef(SvgComponent);
147
+ const MemoForwardRef = React.memo(ForwardRef);
148
+ export default MemoForwardRef;"
142
149
`;
143
150
144
151
exports[`plugin typescript custom templates support basic template 1`] = `
@@ -214,34 +221,23 @@ export default SvgComponent;"
214
221
215
222
exports[`plugin typescript with "ref" and "expandProps" option expands props 1`] = `
216
223
"import * as React from \\"react\\";
217
- interface SVGRProps {
218
- svgRef?: React.Ref<SVGSVGElement>
219
- }
220
224
221
- function SvgComponent({
222
- svgRef,
223
- ...props
224
- }: React.SVGProps<SVGSVGElement> & SVGRProps) {
225
+ function SvgComponent(props: React.SVGProps<SVGSVGElement>, svgRef?: React.Ref<SVGSVGElement>) {
225
226
return <svg><g /></svg>;
226
227
}
227
228
228
- const ForwardRef = React.forwardRef((props, ref: React.Ref<SVGSVGElement>) => < SvgComponent svgRef={ref} {...props} /> );
229
+ const ForwardRef = React.forwardRef(SvgComponent);
229
230
export default ForwardRef;"
230
231
`;
231
232
232
233
exports[`plugin typescript with "ref" option adds ForwardRef component 1`] = `
233
234
"import * as React from \\"react\\";
234
- interface SVGRProps {
235
- svgRef?: React.Ref<SVGSVGElement>
236
- }
237
235
238
- function SvgComponent({
239
- svgRef
240
- }: SVGRProps) {
236
+ function SvgComponent(props: {}, svgRef?: React.Ref<SVGSVGElement>) {
241
237
return <svg><g /></svg>;
242
238
}
243
239
244
- const ForwardRef = React.forwardRef((props, ref: React.Ref<SVGSVGElement>) => < SvgComponent svgRef={ref} {...props} /> );
240
+ const ForwardRef = React.forwardRef(SvgComponent);
245
241
export default ForwardRef;"
246
242
`;
247
243
@@ -262,19 +258,32 @@ function SvgComponent({
262
258
export default SvgComponent;"
263
259
`;
264
260
265
- exports[`plugin typescript with both "memo " and "ref" option wrap component in "React.memo" and "React.forwardRef" 1`] = `
261
+ exports[`plugin typescript with "titleProp " and "expandProps" adds "titleProp", "titleId" props and expands props 1`] = `
266
262
"import * as React from \\"react\\";
267
263
interface SVGRProps {
268
- svgRef?: React.Ref<SVGSVGElement>
264
+ title?: string,
265
+ titleId?: string,
269
266
}
270
267
271
268
function SvgComponent({
272
- svgRef
273
- }: SVGRProps) {
269
+ title,
270
+ titleId,
271
+ ...props
272
+ }: React.SVGProps<SVGSVGElement> & SVGRProps) {
274
273
return <svg><g /></svg>;
275
274
}
276
275
277
- const MemoSvgComponent = React.memo(SvgComponent);
278
- const ForwardRef = React.forwardRef((props, ref: React.Ref<SVGSVGElement>) => <MemoSvgComponent svgRef={ref} {...props} />);
279
- export default ForwardRef;"
276
+ export default SvgComponent;"
277
+ `;
278
+
279
+ exports[`plugin typescript with both "memo" and "ref" option wrap component in "React.memo" and "React.forwardRef" 1`] = `
280
+ "import * as React from \\"react\\";
281
+
282
+ function SvgComponent(props: {}, svgRef?: React.Ref<SVGSVGElement>) {
283
+ return <svg><g /></svg>;
284
+ }
285
+
286
+ const ForwardRef = React.forwardRef(SvgComponent);
287
+ const MemoForwardRef = React.memo(ForwardRef);
288
+ export default MemoForwardRef;"
280
289
`;
0 commit comments