How to show SVG file on React Native?

后端 未结 13 1583
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 11:13

I want to show svg files (I have bunch of svg images) but the thing I couldn\'t find the way to show. I tried to use Image and Use componen

13条回答
  •  粉色の甜心
    2020-12-12 11:36

    I've tried all the above solutions and other solutions outside of the stack and none of working for me. finally, after long research, I've found one solution for my expo project.

    If you need it to work in expo, one workaround might be to use https://react-svgr.com/playground/ and move the spreading of props to a G element instead of the SVG root like this:

    import * as React from 'react';
    import Svg, { G, Path } from 'react-native-svg';
    
    function SvgComponent(props) {
      return (
        
          
            
            
            
          
        
      );
    }
    
    export default function App() {
      return (
        
      );
    }
    

提交回复
热议问题