Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Problems with react-native-svg-transformer and typescript

$
0
0

I decided to add typescript in a existing project and have a issue when a i works with import of .svg like a this

import Icon from "../../../assets/Icon.svg";

i tried configure metro.config.js

const { getDefaultConfig } = require("metro-config");module.exports = (async () => {  const {    resolver: { sourceExts, assetExts },  } = await getDefaultConfig();  return {    transformer: {      babelTransformerPath: require.resolve("react-native-svg-transformer"),    },    resolver: {      assetExts: assetExts.filter((ext) => ext !== "svg"),      sourceExts: [...sourceExts, "svg"],    },  };})();

and add a declarations file

declare module "*.svg" {  import React from "react";  import { SvgProps } from "react-native-svg";  const content: React.FC<SvgProps>;  export default content;}

but it's not work for me, and i get the error

in the terminal

in the phone


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>