use svg on react native code example
Example 1: use svg in react native
npm add react-native-svg --save
npm install react-native-svg-transformer --save
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