Answers for "use svg in react native"

3

react native import svg image

yarn add react-native-svg         
yarn add react-native-svg-uri
npx react-native link react-native-svg
...
import * as React from 'react';
import SvgUri from 'react-native-svg-uri'; // SVG Package
import testSvg from './test.svg';          // SVG File
export default () => (
  <SvgUri width="200" height="200" svgXmlData={testSvg}/>
);
Posted by: Guest on July-29-2021
3

use svg in react native

npm add react-native-svg --save
npm install react-native-svg-transformer --save


//Add this this to 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"]    
		}};
})();
Posted by: Guest on May-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language