kristerkari / react-native-svg-transformer

Import SVG files in your React Native project the same way that you would in a Web application.
MIT License
1.54k stars 116 forks source link

Identifier 'Svg' has already been declared #284

Closed thibaultcapelli closed 10 months ago

thibaultcapelli commented 11 months ago

I have this error when I upgrade to 1.1.0

  1 | import * as React from "react";
  2 | import Svg, { Path } from "react-native-svg";
> 3 | import type { SvgProps, Svg, Path } from "react-native-svg";
pehagg commented 11 months ago

I would encourage you to read the error message and your code again.

You can't import the same declarations twice, the typescript compiler will choke on this. Just use regular imports. Type imports are for more esoteric cases when you run into issues with transpilers. For a detailed description, see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export.

thibaultcapelli commented 11 months ago

Hello @pehagg

I understand the error but the code is not mine. It provide from an SVG I import with this lib. I guess it is the transpiled code. I do not have this issue with the 1.0.0

pehagg commented 11 months ago

@thibaultcapelli , sorry, I missed the "when I upgrade" part. For context, have you upgraded any other libs in your project or is it this lib only?

kristerkari commented 11 months ago

Looks like this is a possible bug in SVGR: https://github.com/gregberge/svgr/issues/891

kristerkari commented 11 months ago

Looks like there is a fix for it: https://github.com/gregberge/svgr/pull/894

kristerkari commented 10 months ago

If you run into this problem, please check that your lockfile is using the 8.1.0 or newer version for the following react-native-svg-transformer dependencies:

@svgr/core
@svgr/plugin-jsx 
@svgr/plugin-svgo