When developing a react native app with expo, I encountered a similar issue before stumbling upon a solution on react-native-svg. I opted for the XML Option, and here's how I went about it.
STEP 1- Initially, I used this resource convert SVG to JSX for React to convert the SVG to JSX (Sometimes conversion may not be necessary, depending on the icon).
STEP 2- Start by creating a new component file and import react along with
import { SvgXml } from 'react-native-svg'
, then establish a normal functional component inside.
STEP 3- Enclose the converted SVG icon tag in Quotation marks like this
"<svg>some icon code inside</svg>"
and store it in a variable (var, const, let..etc.).
STEP 4- Finally, return
<SvgXml xml={the variable goes here} />
.
STEP 5- Export the component as usual.
Below is an example implementation:
import React from 'react'
import { SvgXml } from 'react-native-svg';
function FastRunningIcon(props) {
const xml = `<svg
xmlns="http://www.w3.org/2000/svg"
width="${props.width}"
height="${props.height}"
viewBox="0 0 21.244 20"
>
<path
fill="#595959"
d="M7.379 20a1.21 1.21 0 01-.783-.291.235.235 0 01-.04-.041 1.258 1.258 0 01-.293-1.036 2.179 2.179 0 01.544-1.049c.387-.459 1.089-1.209 2.085-2.231H6.874a1.426 1.426 0 01-1.062-.412 1.263 1.263 0 01-.332-.863 1.166 1.166 0 01.345-.85 1.7 1.7 0 011.01-.425c.454-.05 1.532-.07 2.575-.09h.187c.4-.008.649-.009.869-.01h.506L8.4 8.925 8.38 8.9a2.075 2.075 0 01-.2-1.877 3.3 3.3 0 011.165-1.272l.013-.013L12.412 3.6l-1.221-.957-4.011.094h-.04c-.064 0-.116.007-.168.007a2.209 2.209 0 01-.642-.1 1.271 1.271 0 01-.43-.213.755.755 0 01-.279-.478.014.014 0 00-.006-.006s-.006...
return <SvgXml xml={xml} />
}
export default FastRunningIcon;