react-native-svg not converting correctly - react-native

I cannot convert this svg for use in react native via react-native-svg
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 342.7 256.21"><defs><style>.cls-1{fill:url(#linear-gradient);}.cls-2{fill:url(#linear-gradient-2);}.cls-3{fill:url(#linear-gradient-3);}</style><linearGradient id="linear-gradient" x1="7.39" y1="65.57" x2="78.68" y2="65.57" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#244b9d"/><stop offset="0.99" stop-color="#e27b2d"/></linearGradient><linearGradient id="linear-gradient-2" x1="0" y1="163.98" x2="148.18" y2="163.98" xlink:href="#linear-gradient"/><linearGradient id="linear-gradient-3" x1="68.45" y1="120.84" x2="342.7" y2="120.84" xlink:href="#linear-gradient"/></defs><g id="Layer_2" data-name="Layer 2"><g id="Layer_2-2" data-name="Layer 2"><path class="cls-1" d="M7.39,104l.24-7.2C7.68,95.34,9,60.88,23.45,47,37.52,33.5,49.94,28.73,74.57,27.36l4.11-.23-.44,4.1c0,.46-1.29,11.51-7.59,19.84s-41.57,37-57.45,48.67Zm63.1-69.35c-20,1.57-30.25,5.93-42.2,17.39C19.58,60.4,16.37,79,15.23,89.47,34.31,74.93,60.42,53,65.07,46.85A34.39,34.39,0,0,0,70.49,34.65Z"/><path class="cls-2" d="M83.81,256.21a74,74,0,0,1-11.94-.95A85.58,85.58,0,0,1,7.93,206.49c-10.57-23.69-10.57-48.27,0-73.06,11.49-27,57.07-56.33,59-57.57l6.45-4.12-1.11,7.58c-3.64,24.85-12.69,92-10.91,104.24C63.4,197.74,68.12,205,82.4,216c11.24,8.65,45.05,12.32,57.13,13l8.65.49-6.57,5.65C132.39,243.1,109.85,256.21,83.81,256.21ZM64.2,86.15c-13,9.1-41.66,30.77-49.85,50-9.9,23.25-9.9,45.32,0,67.46A78.47,78.47,0,0,0,73,248.35c23.13,3.75,44.65-5.67,56.6-13.15-14.22-1.43-40.39-5.14-51.46-13.65-15.63-12-21.4-21-23.72-37C52.5,171.43,61,108.57,64.2,86.15Z"/><path class="cls-3" d="M202.06,241.69c-20.22,0-41.94-7.08-58.33-20.13-8.35.14-51.79-.28-68.77-22.69l-6.51-8.58,10.3,3.11c.65.19,14.21,4,24.07-6.5,7.92-8.44,9.62-28.47,11.12-46.14.53-6.22,1-12.1,1.77-17.62,1.69-12.67,9.12-27.23,19.88-38.95a84,84,0,0,1,47.55-26.36L187.9,57l-.69,4.79c-.09.59-8.62,59.63-11.93,89.82-1.51,13.78,4.51,20.71,9.83,24.1,8.17,5.21,19,4.91,24.44,1.64,11.43-6.93,13.06-13.67,14.39-24,1.39-10.8,12.29-91.66,14.95-108.34,3-18.63,21.2-37.82,40.66-42.78,26.83-6.84,48.72,2,58.54,23.59L342.7,36l-9.59-5.69c-2.95-1.75-11.83-5.9-17.3-4.15-7,2.22-12.47,9-13.7,14.26-1.4,5.92-13.36,90.21-17.48,125.74-3.69,31.89-20.32,53.88-52.35,69.2C223.35,239.64,212.92,241.69,202.06,241.69Zm-55.93-27.21,1,.85c23.23,19.1,58.53,25,82.11,13.73,30.05-14.38,45-34,48.42-63.7,3.93-33.91,16-119.53,17.61-126.54S304,22.59,313.69,19.5c4-1.29,8.6-.74,12.59.37C312.86,3.4,291,6.58,281.28,9.05c-18.44,4.7-33.24,23-35.48,37.1-2.65,16.63-13.52,97.35-14.92,108.13-1.45,11.26-3.67,20.54-17.7,29.05-8.52,5.16-22.2,4.42-31.83-1.72-9.89-6.31-14.51-17.23-13-30.77,2.76-25.16,9.12-70.21,11.25-85.12-34.61,8.37-54.37,39.16-56.92,58.35-.72,5.35-1.21,11.15-1.73,17.28-1.68,19.73-3.41,40.13-13,50.34a29.86,29.86,0,0,1-20.65,9.47c19.83,14.59,57.1,13.38,57.53,13.37Z"/></g></g></svg>
My output is
import React, { memo } from 'react'
import Svg, { Defs, LinearGradient, Stop, G, Path } from 'react-native-svg' //12.1.1
const Icon = memo(
({ color, size = 120, style, ...rest }: IconProps) => {
return (
<Svg viewBox="0 0 120 120" width={size} height={size} {...rest}>
<Defs>
<LinearGradient
id="linear-gradient"
x1={7.39}
y1={65.57}
x2={78.68}
y2={65.57}
gradientUnits="userSpaceOnUse"
>
<Stop offset={0} stopColor="#244b9d" />
<Stop offset={0.99} stopColor="#e27b2d" />
</LinearGradient>
<LinearGradient
id="linear-gradient-2"
x1={0}
y1={163.98}
x2={148.18}
y2={163.98}
/>
<LinearGradient
id="linear-gradient-3"
x1={68.45}
y1={120.84}
x2={342.7}
y2={120.84}
/>
</Defs>
<G id="Layer_2" data-name="Layer 2">
<G id="Layer_2-2" data-name="Layer 2">
<Path
d="M7.39 104l.24-7.2C7.68 95.34 9 60.88 23.45 47c14.07-13.5 26.49-18.27 51.12-19.64l4.11-.23-.44 4.1c0 .46-1.29 11.51-7.59 19.84s-41.57 37-57.45 48.67zm63.1-69.35c-20 1.57-30.25 5.93-42.2 17.39C19.58 60.4 16.37 79 15.23 89.47 34.31 74.93 60.42 53 65.07 46.85a34.39 34.39 0 005.42-12.2z"
fill="url(#linear-gradient)"
/>
<Path
d="M83.81 256.21a74 74 0 01-11.94-.95 85.58 85.58 0 01-63.94-48.77c-10.57-23.69-10.57-48.27 0-73.06 11.49-27 57.07-56.33 59-57.57l6.45-4.12-1.11 7.58c-3.64 24.85-12.69 92-10.91 104.24C63.4 197.74 68.12 205 82.4 216c11.24 8.65 45.05 12.32 57.13 13l8.65.49-6.57 5.65c-9.22 7.96-31.76 21.07-57.8 21.07zM64.2 86.15c-13 9.1-41.66 30.77-49.85 50-9.9 23.25-9.9 45.32 0 67.46A78.47 78.47 0 0073 248.35c23.13 3.75 44.65-5.67 56.6-13.15-14.22-1.43-40.39-5.14-51.46-13.65-15.63-12-21.4-21-23.72-37-1.92-13.12 6.58-75.98 9.78-98.4z"
fill="url(#linear-gradient-2)"
/>
<Path
d="M202.06 241.69c-20.22 0-41.94-7.08-58.33-20.13-8.35.14-51.79-.28-68.77-22.69l-6.51-8.58 10.3 3.11c.65.19 14.21 4 24.07-6.5 7.92-8.44 9.62-28.47 11.12-46.14.53-6.22 1-12.1 1.77-17.62 1.69-12.67 9.12-27.23 19.88-38.95a84 84 0 0147.55-26.36l4.76-.83-.69 4.79c-.09.59-8.62 59.63-11.93 89.82-1.51 13.78 4.51 20.71 9.83 24.1 8.17 5.21 19 4.91 24.44 1.64 11.43-6.93 13.06-13.67 14.39-24 1.39-10.8 12.29-91.66 14.95-108.34 3-18.63 21.2-37.82 40.66-42.78 26.83-6.84 48.72 2 58.54 23.59L342.7 36l-9.59-5.69c-2.95-1.75-11.83-5.9-17.3-4.15-7 2.22-12.47 9-13.7 14.26-1.4 5.92-13.36 90.21-17.48 125.74-3.69 31.89-20.32 53.88-52.35 69.2-8.93 4.28-19.36 6.33-30.22 6.33zm-55.93-27.21l1 .85c23.23 19.1 58.53 25 82.11 13.73 30.05-14.38 45-34 48.42-63.7 3.93-33.91 16-119.53 17.61-126.54S304 22.59 313.69 19.5c4-1.29 8.6-.74 12.59.37C312.86 3.4 291 6.58 281.28 9.05c-18.44 4.7-33.24 23-35.48 37.1-2.65 16.63-13.52 97.35-14.92 108.13-1.45 11.26-3.67 20.54-17.7 29.05-8.52 5.16-22.2 4.42-31.83-1.72-9.89-6.31-14.51-17.23-13-30.77 2.76-25.16 9.12-70.21 11.25-85.12-34.61 8.37-54.37 39.16-56.92 58.35-.72 5.35-1.21 11.15-1.73 17.28-1.68 19.73-3.41 40.13-13 50.34a29.86 29.86 0 01-20.65 9.47c19.83 14.59 57.1 13.38 57.53 13.37z"
fill="url(#linear-gradient-3)"
/>
</G>
</G>
</Svg>
)
}
)
No matter what I do it only seems to render the first Path and the rest is missing. it doesn't appear to be cut off by the viewBox either. Not sure what to do to get this svg to render correctly.
How it renders on web
Adding stops get me further but still not working correctly
Update: Adding stop, moving width and height to wrapping View and adjusting the viewport gets the svg to render. however the gradient is messed up on the second and third path
const Icon = memo(
({ color, size = 60, style, ...rest }: IconProps) => {
return (
<View style={{ width: size, height: size }}>
<Svg viewBox="0 0 360 360" {...rest}>
<Defs>
<LinearGradient
id="linear-gradient"
x1={7.39}
y1={65.57}
x2={78.68}
y2={65.57}
gradientUnits="userSpaceOnUse"
>
<Stop offset={0} stopColor="#244b9d" />
<Stop offset={0.99} stopColor="#e27b2d" />
</LinearGradient>
<LinearGradient
id="linear-gradient-2"
x1={0}
y1={163.98}
x2={148.18}
y2={163.98}
>
<Stop offset={0} stopColor="#244b9d" />
<Stop offset={0.99} stopColor="#e27b2d" />
</LinearGradient>
<LinearGradient
id="linear-gradient-3"
x1={68.45}
y1={120.84}
x2={342.7}
y2={120.84}
>
<Stop offset={0} stopColor="#244b9d" />
<Stop offset={0.99} stopColor="#e27b2d" />
</LinearGradient>
</Defs>
<G id="Layer_2" data-name="Layer 2">
<G id="Layer_2-2" data-name="Layer 2">
<Path
d="M7.39 104l.24-7.2C7.68 95.34 9 60.88 23.45 47c14.07-13.5 26.49-18.27 51.12-19.64l4.11-.23-.44 4.1c0 .46-1.29 11.51-7.59 19.84s-41.57 37-57.45 48.67zm63.1-69.35c-20 1.57-30.25 5.93-42.2 17.39C19.58 60.4 16.37 79 15.23 89.47 34.31 74.93 60.42 53 65.07 46.85a34.39 34.39 0 005.42-12.2z"
fill="url(#linear-gradient)"
/>
<Path
d="M83.81 256.21a74 74 0 01-11.94-.95 85.58 85.58 0 01-63.94-48.77c-10.57-23.69-10.57-48.27 0-73.06 11.49-27 57.07-56.33 59-57.57l6.45-4.12-1.11 7.58c-3.64 24.85-12.69 92-10.91 104.24C63.4 197.74 68.12 205 82.4 216c11.24 8.65 45.05 12.32 57.13 13l8.65.49-6.57 5.65c-9.22 7.96-31.76 21.07-57.8 21.07zM64.2 86.15c-13 9.1-41.66 30.77-49.85 50-9.9 23.25-9.9 45.32 0 67.46A78.47 78.47 0 0073 248.35c23.13 3.75 44.65-5.67 56.6-13.15-14.22-1.43-40.39-5.14-51.46-13.65-15.63-12-21.4-21-23.72-37-1.92-13.12 6.58-75.98 9.78-98.4z"
fill="url(#linear-gradient-2)"
/>
<Path
d="M202.06 241.69c-20.22 0-41.94-7.08-58.33-20.13-8.35.14-51.79-.28-68.77-22.69l-6.51-8.58 10.3 3.11c.65.19 14.21 4 24.07-6.5 7.92-8.44 9.62-28.47 11.12-46.14.53-6.22 1-12.1 1.77-17.62 1.69-12.67 9.12-27.23 19.88-38.95a84 84 0 0147.55-26.36l4.76-.83-.69 4.79c-.09.59-8.62 59.63-11.93 89.82-1.51 13.78 4.51 20.71 9.83 24.1 8.17 5.21 19 4.91 24.44 1.64 11.43-6.93 13.06-13.67 14.39-24 1.39-10.8 12.29-91.66 14.95-108.34 3-18.63 21.2-37.82 40.66-42.78 26.83-6.84 48.72 2 58.54 23.59L342.7 36l-9.59-5.69c-2.95-1.75-11.83-5.9-17.3-4.15-7 2.22-12.47 9-13.7 14.26-1.4 5.92-13.36 90.21-17.48 125.74-3.69 31.89-20.32 53.88-52.35 69.2-8.93 4.28-19.36 6.33-30.22 6.33zm-55.93-27.21l1 .85c23.23 19.1 58.53 25 82.11 13.73 30.05-14.38 45-34 48.42-63.7 3.93-33.91 16-119.53 17.61-126.54S304 22.59 313.69 19.5c4-1.29 8.6-.74 12.59.37C312.86 3.4 291 6.58 281.28 9.05c-18.44 4.7-33.24 23-35.48 37.1-2.65 16.63-13.52 97.35-14.92 108.13-1.45 11.26-3.67 20.54-17.7 29.05-8.52 5.16-22.2 4.42-31.83-1.72-9.89-6.31-14.51-17.23-13-30.77 2.76-25.16 9.12-70.21 11.25-85.12-34.61 8.37-54.37 39.16-56.92 58.35-.72 5.35-1.21 11.15-1.73 17.28-1.68 19.73-3.41 40.13-13 50.34a29.86 29.86 0 01-20.65 9.47c19.83 14.59 57.1 13.38 57.53 13.37z"
fill="url(#linear-gradient-3)"
/>
</G>
</G>
</Svg>
</View>
)
}
)
Result

Related

SVG icon showing cutoff on android in react native

I am using lib react-native-svg to display SVG in my mobile app. In iOS, it is showing properly but on android, it shows cutoff. I will also attach a screenshot for reference, Can someone please help me how to solve this problem?
iOS Screenshot
Android Screenshot
SVG snap
export const SVGIcon = (props: SvgProps) => (
<Svg
width={170}
height={150}
style={{ marginRight: 12, marginTop: 1 }}
fill="none"
viewbox="0 0 46 46"
xmlns="http://www.w3.org/2000/svg"
{...props}>
<Mask
id="a"
style={{
maskType: 'alpha',
}}
maskUnits="userSpaceOnUse"
x={21}
y={7}
width={136}
height={135}>
<Rect
x={21.25}
y={7.25}
width={135.5}
height={134.5}
rx={19.75}
fill="#fff"
stroke="#FAB405"
strokeWidth={0.5}
/>
</Mask>
<G mask="url(#a)">
<Path d="M129.103 84.136h-84.34v31.103h84.34V84.136Z" fill="#3E3E3E" />
<Path
d="M105.994 130.267c9.806 0 17.756-7.957 17.756-17.773 0-9.815-7.95-17.772-17.756-17.772-9.806 0-17.755 7.957-17.755 17.772 0 9.816 7.95 17.773 17.755 17.773Z"
fill="#111"
/>
<Path
d="M105.994 122.295c5.408 0 9.792-4.388 9.792-9.801s-4.384-9.801-9.792-9.801c-5.407 0-9.791 4.388-9.791 9.801s4.384 9.801 9.791 9.801Z"
fill="#F1F1F1"
/>
<Path
d="M105.994 120.727c4.543 0 8.225-3.686 8.225-8.233 0-4.547-3.682-8.233-8.225-8.233-4.542 0-8.225 3.686-8.225 8.233 0 4.547 3.683 8.233 8.225 8.233Z"
fill="#BCBCBC"
/>
<Path
d="m-33.047 96.682 2.61 21.693H84.845s-1.305-21.301 13.84-26.398c15.144-5.096 30.68 5.358 28.46 25.614l16.189-.392s1.958.261 1.567-3.136c-.392-3.398 0-14.245 0-14.245l-1.567-1.96-1.828-20.648s-.652-3.397-8.616-5.75c-7.964-2.352-36.817-8.494-36.817-8.494s-2.611-1.046-3.394-2.222c-.784-1.176-15.798-26.267-15.798-26.267s-3.002-1.96-4.177-2.744c0 0-6.92-15.943-31.464-22.477C16.694 2.722-13.203.239-13.203.239h-4.047v93.045h-14.883l-.914 3.398Z"
fill="#F5A81F"
/>
<Path
d="M-33.047 96.682h84.73l4.178 6.534h30.811v18.034h-119.72l-3.133-24.568h3.134Z"
fill="#3E3E3E"
/>
<Mask
id="b"
style={{
maskType: 'alpha',
}}
maskUnits="userSpaceOnUse"
x={-33}
y={-1}
width={179}
height={120}>
<Path
d="m-32.917 96.42 2.611 21.694h115.28s-1.305-21.302 13.84-26.398c15.144-5.097 30.68 5.358 28.461 25.614l16.189-.392s1.958.261 1.566-3.137c-.391-3.398 0-14.244 0-14.244l-1.566-1.96-1.828-20.648s-.653-3.398-8.617-5.75-36.816-8.494-36.816-8.494-2.611-1.046-3.395-2.222c-.783-1.176-15.797-26.267-15.797-26.267s-3.003-1.96-4.178-2.744c0 0-6.92-15.944-31.464-22.478C16.825 2.46-13.072-.023-13.072-.023h-4.047v93.046h-14.884l-.914 3.398Z"
fill="#F5A81F"
/>
</Mask>
<G mask="url(#b)">
<Path
d="M144.769 103.216s-3.655-15.682-22.977-18.426c-19.323-2.745-30.681-.262-41.778 18.426l-2.35 14.636 69.325-1.045-2.22-13.591Z"
fill="#FFC533"
/>
</G>
<Path
d="M52.858 35h17.756L86.28 61.136 78.84 72.898h-25.98V35Z"
fill="#DEDEDC"
/>
<Path
d="M22.047 9.517v83.636"
stroke="#FFC533"
strokeWidth={0.25}
strokeMiterlimit={10}
/>
<Path
d="M22.047 101.909v12.807"
stroke="#1E1E1E"
strokeWidth={0.25}
strokeMiterlimit={10}
/>
<Path
d="M78.055 93.153H-12.81"
stroke="#FFC533"
strokeWidth={0.25}
strokeMiterlimit={10}
/>
<Path d="M78.055 112.494H-34.614v5.228h112.67v-5.228Z" fill="#111" />
<Mask
id="c"
style={{
maskType: 'alpha',
}}
maskUnits="userSpaceOnUse"
x={46}
y={24}
width={41}
height={50}>
<Path
d="m50.639 73.16-3.917-46.393.653-1.96 32.639 3.267 6.528 33.324-7.834 11.761h-28.07Z"
fill="#C4C4C4"
/>
</Mask>
<G mask="url(#c)">
<Path
d="m55.73 49.767 4.831 3.006c.783-.915 1.306-2.091 1.697-3.006 0-.13.13-.261.13-.523.393-.914.523-1.83.784-2.483 0-.13 0-.261.13-.261.131-.523-2.61-1.568-4.177-2.222-.522-.261-.914-.392-1.044-.522 0 0 .26.653.26 1.045 0 1.046-.26 1.83-.783 2.483-1.044 1.699-1.828 2.483-1.828 2.483Z"
fill="#FFAE73"
/>
<Path
d="M57.95 44.932s1.697 4.051 4.439 4.835c0-.13.13-.261.13-.523.392-.914.523-1.83.784-2.483-.392-.522-2.742-1.437-4.178-2.09-.783.13-1.175.26-1.175.26Z"
fill="#F9924F"
/>
<Path
d="M63.694 47.415s-6.136 1.83-7.18-2.091c-1.045-3.92-2.611-6.273 1.305-7.58 3.917-1.306 5.092 0 5.745 1.176 1.828 3.137.914 6.012.13 8.495Z"
fill="#FFAE73"
/>
<Path
d="M64.87 58.784s8.616 9.279 15.797 11.108c0 0 2.22 0 2.61-2.875.262-1.83-14.1-14.767-18.538-14.898-4.308-.13-1.175 4.705.13 6.665Z"
fill="#427C4D"
/>
<Path
d="M57.558 84.006c.523 1.437 1.436 2.483 2.611 2.875 1.306.522 3.134.522 5.092 0 2.35-.523 4.7-1.569 6.658-2.483 1.045-.523 1.959-1.176 2.48-1.568 2.743-2.222-7.18-4.836-5.613-12.546 3.133-15.551-3.133-17.25-4.308-18.818-2.22-2.744-8.747-.392-8.747-.392-1.175 1.699-2.09 3.92-2.35 7.318-.131 1.307 0 3.136.391 5.227.914 6.273 3.003 14.375 3.134 16.335 0 1.569.26 2.876.652 4.052Z"
fill="#759F7E"
/>
<Path
d="M55.992 47.938s-.523 2.874-.261 3.267c0 0 6.136-.654 9.008.522 0 0-1.306-2.352-2.48-2.875-1.045-.392-6.267-.914-6.267-.914ZM54.817 62.051c6.92 6.142 14.491-4.966 14.491-4.966-.653-1.045-1.697-1.83-3.003-2.352-3.263 1.568-7.31 4.313-8.486 4.705-.652.13-2.48 2.09-3.002 2.613Z"
fill="#427C4D"
/>
<Path
d="M55.861 52.12s-3.003 8.886-4.57-2.222c-.13-1.307 1.045-6.142.784-8.103-.261-2.09-1.567-3.79.783-5.358 2.22-1.568 2.22-2.221 3.656-2.613 1.436-.392 3.655.523 4.83.13 1.175-.392 5.484 4.313 3.134 5.75 0 0-2.48-2.613-3.525-.522-.392.784-1.828.261-1.567 1.176 1.567 7.58-2.089 11.761-3.525 11.761Z"
fill="#282828"
/>
<Path
d="M55.992 63.358s11.75-4.574 17.755-9.017c0 0 .914-2.222-.392-3.529-1.305-1.176-15.536.654-18.408 4.052-2.872 3.397-1.436 8.363 1.045 8.494Z"
fill="#759F7E"
/>
<Path
d="M73.356 36.699s.913-1.046.391-1.568c-.522-.523-1.175-1.7-.914-2.875.261-1.176 1.436-3.267 2.22-2.483.783.784.26 2.875.26 3.397 0 .523.523 1.046.393 1.96-.131.915-.653 1.96-.653 1.96l-1.697-.391Z"
fill="#FFAE73"
/>
<Path
d="m73.094 35.392-3.786 15.16 4.44 3.789s1.305-3.92 2.088-9.54c.914-6.011 0-8.364 0-8.364s-1.567-2.744-2.742-1.045Z"
fill="#759F7E"
/>
</G>
</G>
</Svg>
);
Your SVG has a couple of problems. One is that the viewBox is the wrong size for your picture. It is a lot smaller than the SVG contents. But since the SVG mostly displays, I don't think that's your main problem.
Your SVG uses mask-type: alpha masks. It might be that that is the problem. Maybe they are not properly supported on Android. Or perhaps the parsing and rendering of masks is a bit broken in the Android version of react-native-svg.
Things to try:
Those two masks don't need to be type alpha masks. Remove the style="mask-type: alpha" from both masks, and the SVG will still look the same. Maybe they'll also render correctly then.
Try is modifying your SVG to not use masks. One mask just creates the rounded rectangle outline shape of the icon. That could be changed to a clip. The other mask just cuts out the bottom arch from the bus fender. You could remove the mask by modifying the fender shape, and colour.

How to render a point on a gradient arc?

So I have an SVG component that renders an arc with a color gradient as shown below. Currently, it's just the arc but no grey point. What I want to do is programmatically pass values into the component so that the grey dot moves along the arc as the value passed into the component get higher. How do I do that?
function SvgComponent(props) {
return (
<Svg
xmlns="http://www.w3.org/2000/svg"
width={321}
height={161}
viewBox="0 0 321 161"
fill="none"
{...props}
>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M230.036 39.195l10-17.32A160 160 0 01298.6 80.439l-17.321 10a139.984 139.984 0 00-51.243-51.244z"
fill="url(#prefix__paint0_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M281.279 90.439a139.997 139.997 0 0118.757 70h20a160 160 0 00-21.436-80l-17.321 10z"
fill="url(#prefix__paint1_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M240.036 21.875a160 160 0 00-80-21.436v20a139.994 139.994 0 0170 18.756l10-17.32z"
fill="url(#prefix__paint2_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M160.036.439a160.001 160.001 0 00-80 21.436l10 17.32a140.003 140.003 0 0170-18.756v-20z"
fill="url(#prefix__paint3_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M38.792 90.439l-17.32-10a160 160 0 0158.564-58.564l10 17.32A139.998 139.998 0 0038.792 90.44z"
fill="url(#prefix__paint4_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M20.041 160.441a139.994 139.994 0 0118.757-70l-17.32-10a159.998 159.998 0 00-21.437 80h20z"
fill="url(#prefix__paint5_linear)"
/>
<Defs>
<LinearGradient
id="prefix__paint0_linear"
x1={291.5}
y1={79}
x2={287.596}
y2={26.447}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#863030" />
<Stop offset={1} stopColor="#862BB0" />
</LinearGradient>
<LinearGradient
id="prefix__paint1_linear"
x1={294}
y1={89.5}
x2={326.552}
y2={147.819}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#863030" />
<Stop offset={1} stopColor="#481717" />
</LinearGradient>
<LinearGradient
id="prefix__paint2_linear"
x1={240}
y1={31.5}
x2={180.5}
y2={9.5}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#862BB0" />
<Stop offset={1} stopColor="#D12020" />
</LinearGradient>
<LinearGradient
id="prefix__paint3_linear"
x1={89}
y1={26.5}
x2={156}
y2={12.5}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#DB7326" />
<Stop offset={1} stopColor="#D12020" />
</LinearGradient>
<LinearGradient
id="prefix__paint4_linear"
x1={73}
y1={35.5}
x2={24.5}
y2={90}
gradientUnits="userSpaceOnUse"
>
<Stop offset={0.004} stopColor="#DB7326" />
<Stop offset={0.8} stopColor="#EFC02E" />
</LinearGradient>
<LinearGradient
id="prefix__paint5_linear"
x1={29}
y1={90}
x2={10.992}
y2={160.377}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#EFC02E" />
<Stop offset={0.924} stopColor="#3E7821" />
</LinearGradient>
</Defs>
</Svg>
)
}
export default SvgComponent
The arc was made using SVGR (a tool that takes SVG and turns it into React components).
You can try adding this as a child in the Svg component
<Svg
xmlns="http://www.w3.org/2000/svg"
width={321}
height={161}
viewBox="0 0 321 161"
fill="none"
>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M230.036 39.195l10-17.32A160 160 0 01298.6 80.439l-17.321 10a139.984 139.984 0 00-51.243-51.244z"
fill="url(#prefix__paint0_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M281.279 90.439a139.997 139.997 0 0118.757 70h20a160 160 0 00-21.436-80l-17.321 10z"
fill="url(#prefix__paint1_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M240.036 21.875a160 160 0 00-80-21.436v20a139.994 139.994 0 0170 18.756l10-17.32z"
fill="url(#prefix__paint2_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M160.036.439a160.001 160.001 0 00-80 21.436l10 17.32a140.003 140.003 0 0170-18.756v-20z"
fill="url(#prefix__paint3_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M38.792 90.439l-17.32-10a160 160 0 0158.564-58.564l10 17.32A139.998 139.998 0 0038.792 90.44z"
fill="url(#prefix__paint4_linear)"
/>
<Path
fillRule="evenodd"
clipRule="evenodd"
d="M20.041 160.441a139.994 139.994 0 0118.757-70l-17.32-10a159.998 159.998 0 00-21.437 80h20z"
fill="url(#prefix__paint5_linear)"
/>
<Circle
cx="50%"
cy={10}
r={thickness}
stroke="none"
fill="#fff"
transform={`rotate(${(target / 100) * 180},${321 / 2},${321 / 2})`}
/>
<Defs>
<LinearGradient
id="prefix__paint0_linear"
x1={291.5}
y1={79}
x2={287.596}
y2={26.447}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#863030" />
<Stop offset={1} stopColor="#862BB0" />
</LinearGradient>
<LinearGradient
id="prefix__paint1_linear"
x1={294}
y1={89.5}
x2={326.552}
y2={147.819}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#863030" />
<Stop offset={1} stopColor="#481717" />
</LinearGradient>
<LinearGradient
id="prefix__paint2_linear"
x1={240}
y1={31.5}
x2={180.5}
y2={9.5}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#862BB0" />
<Stop offset={1} stopColor="#D12020" />
</LinearGradient>
<LinearGradient
id="prefix__paint3_linear"
x1={89}
y1={26.5}
x2={156}
y2={12.5}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#DB7326" />
<Stop offset={1} stopColor="#D12020" />
</LinearGradient>
<LinearGradient
id="prefix__paint4_linear"
x1={73}
y1={35.5}
x2={24.5}
y2={90}
gradientUnits="userSpaceOnUse"
>
<Stop offset={0.004} stopColor="#DB7326" />
<Stop offset={0.8} stopColor="#EFC02E" />
</LinearGradient>
<LinearGradient
id="prefix__paint5_linear"
x1={29}
y1={90}
x2={10.992}
y2={160.377}
gradientUnits="userSpaceOnUse"
>
<Stop stopColor="#EFC02E" />
<Stop offset={0.924} stopColor="#3E7821" />
</LinearGradient>
</Defs>
</Svg>
I added this for the white circle
<Circle
cx="50%"
cy={10}
r={thickness}
stroke="none"
fill="#fff"
transform={`rotate(${(target / 100) * 180},${321 / 2},${321 / 2})`}
/>
target should be any value between -50 and 50 with 50 being the max.

How to show gradient SVG image in React Native

I tried the lib react-native-svg-uri to show my gradient SVG but its background was black in screen as attached picture.
Anything is wrong with my code below while I follow guide in this link: https://www.npmjs.com/package/react-native-svg
const iconSvg = require('../images/home_option2/bao_cao.svg')
<SvgUri height={96} width={96} source={iconSvg}/>
Here is SVG code:
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
<defs>
<linearGradient id="a" x1="50%" x2="50%" y1="0%" y2="100%">
<stop offset="0%" stop-color="#68B9FE"/>
<stop offset="100%" stop-color="#627CFF"/>
</linearGradient>
</defs>
<g fill="none" fill-rule="evenodd">
<rect width="48" height="48" fill="url(#a)" rx="24"/>
<path fill="#FFF" d="M17.02 14.692v17.03c0 .406-.334.74-.741.74a.743.743 0 0 1-.74-.74V16.384h-.847A1.69 1.69 0 0 0 13 18.077v15.23A1.69 1.69 0 0 0 14.692 35h18.674c.899 0 1.634-.73 1.634-1.634V14.692A1.69 1.69 0 0 0 33.308 13l-14.702.106c-.936 0-1.587.65-1.587 1.586zm3.49 1.693h4.442c.407 0 .74.333.74.74s-.333.74-.74.74H20.51a.743.743 0 0 1-.74-.74c0-.407.332-.74.74-.74zm0 8.461h7.827c.407 0 .74.333.74.74 0 .408-.333.74-.74.74H20.51a.743.743 0 0 1-.74-.74c0-.407.332-.74.74-.74zm10.365 5.712H20.51a.743.743 0 0 1-.74-.74c0-.408.332-.741.74-.741h10.365c.407 0 .74.333.74.74 0 .408-.333.74-.74.74zm0-8.462H20.51a.743.743 0 0 1-.74-.74c0-.407.332-.74.74-.74h10.365c.407 0 .74.333.74.74s-.333.74-.74.74z"/>
</g>
</svg>
Anyone can help, please!
The problem lies in your .svg file. You are probably using an older svg standard. I transformed your .svg file and with the new one it works.
New SVG:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><g><path d="M48,24c0,-13.246 -10.754,-24 -24,-24c-13.246,0 -24,10.754 -24,24c0,13.246 10.754,24 24,24c13.246,0 24,-10.754 24,-24Z" style="fill:url(#_Linear1);"/><path d="M17.02,14.692l0,17.03c0,0.406 -0.334,0.74 -0.741,0.74c-0.405,-0.002 -0.738,-0.335 -0.74,-0.74l0,-15.338l-0.847,0c-0.001,0 -0.001,0 -0.002,0c-0.927,0 -1.69,0.763 -1.69,1.69c0,0.001 0,0.002 0,0.003l0,15.23c0,0.001 0,0.002 0,0.003c0,0.927 0.763,1.69 1.69,1.69c0.001,0 0.001,0 0.002,0l18.674,0c0.899,0 1.634,-0.73 1.634,-1.634l0,-18.674c0,-0.001 0,-0.001 0,-0.002c0,-0.927 -0.763,-1.69 -1.69,-1.69c-0.001,0 -0.001,0 -0.002,0l-14.702,0.106c-0.936,0 -1.587,0.65 -1.587,1.586l0.001,0Zm3.49,1.693l4.442,0c0.407,0 0.74,0.333 0.74,0.74c0,0.407 -0.333,0.74 -0.74,0.74l-4.442,0c-0.405,-0.002 -0.738,-0.335 -0.74,-0.74c0,-0.407 0.332,-0.74 0.74,-0.74Zm0,8.461l7.827,0c0.407,0 0.74,0.333 0.74,0.74c0,0.408 -0.333,0.74 -0.74,0.74l-7.827,0c-0.405,-0.002 -0.738,-0.335 -0.74,-0.74c0,-0.407 0.332,-0.74 0.74,-0.74Zm10.365,5.712l-10.365,0c-0.405,-0.002 -0.738,-0.335 -0.74,-0.74c0,-0.408 0.332,-0.741 0.74,-0.741l10.365,0c0.407,0 0.74,0.333 0.74,0.74c0,0.408 -0.333,0.74 -0.74,0.74l0,0.001Zm0,-8.462l-10.365,0c-0.405,-0.002 -0.738,-0.335 -0.74,-0.74c0,-0.407 0.332,-0.74 0.74,-0.74l10.365,0c0.407,0 0.74,0.333 0.74,0.74c0,0.407 -0.333,0.74 -0.74,0.74Z" style="fill:#fff;"/></g><defs><linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.93915e-15,48,-48,2.93915e-15,24,0)"><stop offset="0" style="stop-color:#68b9fe;stop-opacity:1"/><stop offset="1" style="stop-color:#627cff;stop-opacity:1"/></linearGradient></defs></svg>
Demo:
import SvgUri from 'react-native-svg-uri';
import img from './test2.svg'; // import .svg file
<SvgUri
width="200"
height="200"
source={img}
/>
Result:

LinearGradient in react-native-svg not working

I am trying to use SVG in my react native project. This is the code for my component:
<Svg xmlns="http://www.w3.org/2000/svg" width="100%" height="507" viewBox="0 0 375 507" style={{position:'absolute', bottom:0}}>
<Defs>
<ClipPath id="a">
<Rect class="a" fill='#fff' stroke='#707070' width="375" height="507" transform="translate(0 160)" d="M0 0h375v507H0z"/>
</ClipPath>
<LinearGradient id="b" clipPath='url(#a)' x1="0.5" x2="-0.031" y2="1.477" gradientUnits="objectBoundingBox">
<Stop offset="0" stopColor="rgb(76,209,149)" />
<Stop offset="1" stopColor="rgb(170,221,100)" />
</LinearGradient>
</Defs>
<G class="b" transform="translate(0 -160)">
<Circle class="c" cx="334.249" cy="334.249" r="334.249" transform="translate(-146.354 164.646)" fill='url(#b)' />
</G>
</Svg>
The Output I'm getting is:
https://i.stack.imgur.com/mGaBg.png
I think #enxaneta is right, clip-path seems to not exist on react-native-svg please refer to the documentation, you may find on the docs here react-native-svg #LinearGradient
I think you should have to reference it like this:
<Rect class="a" fill="url(#yourGradientId)" stroke='#707070' width="375" height="507" transform="translate(0 160)" d="M0 0h375v507H0z"/>
where fill should be reference to your gradient id i.e. fill=url(#b)
I've used <Path> to achieve the results below
Note: I have achieve this by using two shapes on top of each other:
A component with background gradient using react-native-linear-gradient
And the LinearGradient from react-native-linear-gradient
Please refer to the codes below.
Code of example above
import Svg, { Path, Defs, LinearGradient, Stop } from 'react-native-svg';
import Gradient from 'react-native-linear-gradient'
const { width, height } = Dimensions.get('window')
<Gradient style={{height: height * .25,}}
colors={ ['#FFD080', 'red'] }
start={{ x: 0, y: 0}}
end={{ x:1, y: 1}}
locations={[0.18, 1, 1]}>
<Svg
height={height * .44}
width={width}
viewBox="0 0 1440 320"
style={{ position: 'relative', top: height * .069 }}
>
<Defs>
<LinearGradient id="path" x1="0" y1="0" x2="1" y2="1">
<Stop offset="0" stopColor="#FFD080" stopOpacity="1" />
<Stop offset="1" stopColor="red" stopOpacity="1" />
</LinearGradient>
</Defs>
<Path fill="url(#path)"
d="M0,96L48,133.3C96,171,192,245,288,229.3C384,213,480,107,576,74.7C672,43,768,85,864,133.3C960,181,1056,235,1152,234.7C1248,235,1344,181,1392,154.7L1440,128L1440,0L1392,0C1344,0,1248,0,1152,0C1056,0,960,0,864,0C768,0,672,0,576,0C480,0,384,0,288,0C192,0,96,0,48,0L0,0Z"/>
</Svg>
</Gradient>
I found a solution that instead of using the svgs having gradient,I converted the SVG into a Lottie file. that works great and as an extra advantage, we can transform the SVG into a simple animation :)

Does pdf (or svg) support linear interpolation of colors inside a vector graphics triangle?

We would like to blend colors specified at triangle vertices using linear interpolation (e.g. like OpenGL) in a vector graphics file like a pdf.
This example blends red, blue and green:
Is this possible in PDF? If not, then SVG or some other well-supported vector graphics file-format?
It seems gradient meshes are powerful, but can they be degenerated to exactly reproduce linear interpolation?
The pure answer to your question is "no". You can't do three-point gradients in SVG or PDF.
However you can reproduce that image easily enough with a couple of gradients and a mask.
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 100 86.6">
<defs>
<linearGradient id="bluegreen" gradientUnits="objectBoundingBox" x1="0.5" x2="1" y2="1">
<stop offset="0%" stop-color="#0000ff"/>
<stop offset="100%" stop-color="#00ff00"/>
</linearGradient>
<linearGradient id="fader" gradientUnits="objectBoundingBox" x1="0" y1="1" x2="0.75" y2="0.5">
<stop offset="0%" stop-color="white" />
<stop offset="100%" stop-color="black" />
</linearGradient>
<mask id="redmask" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox">
<path d="M 0.5,0 L 1,1 0,1 Z" fill="url(#fader)" />
</mask>
</defs>
<g>
<path d="M 50,0 L 100,86.6 0,86.6 Z" fill="url(#bluegreen)"/>
<path d="M 50,0 L 100,86.6 0,86.6 Z" fill="#ff0000" mask="url(#redmask)"/>
</g>
</svg>
http://jsfiddle.net/P48FD/
Update: Actually, what was I thinking? :/ You don't need a mask. You can do it just with two linear gradients.
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 100 86.6">
<defs>
<linearGradient id="bluegreen" gradientUnits="objectBoundingBox" x1="0.5" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#0000ff"/>
<stop offset="100%" stop-color="#00ff00"/>
</linearGradient>
<linearGradient id="redfade" gradientUnits="objectBoundingBox" x1="0" y1="1" x2="0.75" y2="0.5">
<stop offset="0%" stop-color="#ff0000" />
<stop offset="100%" stop-color="#ff0000" stop-opacity="0" />
</linearGradient>
</defs>
<g>
<path d="M 50,0 L 100,86.6 0,86.6 Z" fill="url(#bluegreen)"/>
<path d="M 50,0 L 100,86.6 0,86.6 Z" fill="url(#redfade)"/>
</g>
</svg>
http://jsfiddle.net/Q3qjB/