svg code to react native code example

Example 1: 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"]    
		}};
})();

Example 2: react-native-svg

yarn add react-native-svg