Receiving "invalidcharactererror: String Contains An Invalid Character" From Importing Svgs With Gatsby-plugin-react-svg
I was using font-awesome svg icons, but I realized that they might be having a significant effect on the LCP of my website, so I'm trying to replace them. I went into my html and c
Solution 1:
The included folder is a regular expression so, it must only contain a single path,/svg/
in your case. In addition, you need to remove the double quotes (what is causing your error since it's an invalid character):
{
resolve: 'gatsby-plugin-react-svg',
options: {
rule: {
include: /svg/
}
}
}
The rest of the code looks good.
Keep in mind that if the SVG shares any ID
inside, it may cause severe issues since they will be replaced for the following inlined SVG. The ID
s inside the SVG shapes must be different for each vector.
Solution 2:
From the create-react-app docs for adding SVG images as react components
Note: this feature is available with
react-scripts@2.0.0
and higher, andreact@16.3.0
and higher.
https://create-react-app.dev/docs/adding-images-fonts-and-files/
Try
import { ReactComponentasFacebookIcon } from'../images/svg/facebookF.svg';
import { ReactComponentasEmail } from'../images/svg/email.svg';
...
<FacebookIcon />
<Email />
Post a Comment for "Receiving "invalidcharactererror: String Contains An Invalid Character" From Importing Svgs With Gatsby-plugin-react-svg"