Getting undefined when importing svg as ReactComponent in create-react-app project

前端 未结 5 960
礼貌的吻别
礼貌的吻别 2021-02-18 18:56

I\'m getting following error when trying to load svg as ReactComponent.

Element type is invalid: expected a string (for built-in components) or a class/fu

5条回答
  •  既然无缘
    2021-02-18 19:51

    use this way this is an exaple find your svg and put it in this function

    your svg file

    interface IProps {
      fill?: string;
    }
    export default (props: IProps) => (
      
        
        
        
      
    );
    

    where you want to use svg

    import React from "react";
    import Menu from "./assets/svg/menu";
    
     ...
     return (
       ...
        
     )
    

提交回复
热议问题