Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: unknown: Namespace tags are not supported by default

Tags:

reactjs

svg

I get the following error when trying to download svg as a React Component.

SyntaxError: unknown: Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can turn on the 'throwIfNamespace' flag to bypass this warning.

import React from "react";
import { ReactComponent as LO } from "../a/Logo.svg"
import { NavLink } from "react-router-dom";

const Logo = () => (
  <>
    <NavLink to={"/"}>
     <LO width={"40px"} height={"40px"} />
    </NavLink>
  </>
);

export default Logo;

What is the reason ?

like image 933
Silicum Silium Avatar asked Jan 20 '20 10:01

Silicum Silium


2 Answers

In the SVG file, try changing:

    sketch:type TO sketchType
    xmlns:xlink TO xmlnsXlink
    xlink:href  TO xlinkHref

etc...

The idea is to create camelCase property, remember that you are working with JSX, you are not creating a string as XML does.

like image 92
Frawel Avatar answered Nov 17 '22 04:11

Frawel


Since we are in the JSX playground your SVG tags should be written as camelCase

So you can easily optimize your SVG using the link below to avoid this error :)

svgminify

like image 31
Ahmad Salih Avatar answered Nov 17 '22 05:11

Ahmad Salih