I'm loading an SVG in a react app. The SVG references an external style sheet.
If I move the SVG out of the JSX and into the index.html, the SVG uses the defined css class.
If I use a a library such as react-svg, the svg is loading the external css class in JSX.
Why does the SVG not load the external CSS when using the SVG in JSX?
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import ReactSVG from 'react-svg'
class App extends Component {
render() {
return (
<object data={logo} className="App-logo" type="image/svg+xml"></object>
);
}
}
export default App;
<?xml-stylesheet type="text/css" href="./App.css" ?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g class='svgTestFill'>
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 ..."/>
<circle cx="420.9" cy="296.5" r="45.7"/>
<path d="M520.5 78.1z"/>
</g>
</svg>
This should render the logo with a red fill. I also do not want to use the SVG inline. I have to import the SVG as an object.
After inspecting network requests, the CSS file I'm referencing in the SVG is returned from the create-react app as an HTML page, not CSS. Maybe this is the problem?