import React, { useMemo } from 'react'; import { View } from 'react-native'; import times from 'lodash-es/times'; import colorTools from 'color'; import Svg, { Defs, Rect, LinearGradient as LinearGradientSvg, Stop } from 'react-native-svg'; import type { LinearGradientProps } from './types'; const LinearGradient = (props: LinearGradientProps): JSX.Element => { const { colors, start = { x: 0.5, y: 0.0 }, end = { x: 0.5, y: 1.0 }, locations, ...rest } = props; const offsets = useMemo(() => { return locations ? locations.slice(0, colors.length) : times(colors.length, (idx: number) => (idx * 1) / (colors.length - 1)); }, [locations, colors]); return ( {colors.map((color, idx) => ( ))} ); }; export default LinearGradient;