Yes.
Yes
svg
I cannot provide you environment info since I am getting the following error:
npx create-react-app --info
npx: installed 1 in 2.366s
Path must be a string. Received undefined
C:\Users\dxh06AppData\Roaming\npm\node_modulescreate-react-app\index.jsEnvironment Info:
(node:12112) UnhandledPromiseRejectionWarning: Error: The system cannot find the path specified.
Importing a svg file as a React component generates an error at run-time. See code below.
The svg should become a standard Rect Component like stated by svgr.
When I import a svg and use it as a React component I am getting the following error at run-time:
InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('/static/media/logo.5d5d9eef.svg') is not a valid name.
â–¶ 20 stack frames were collapsed.
Module../src/index.js
C:/Git/web-react-components-library/src/index.js:74 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | > 7 | ReactDOM.render(<App />, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls.
import React, { Component } from 'react';
import Logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<Logo></Logo>
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
}
export default App;
May be related to #5276.
You wrote:
import Logo from './logo.svg';
The User Guide says:
import { ReactComponent as Logo } from './logo.svg';
Don't forget the curly braces in the import! The
ReactComponent
import name is special and tells Create React App that you want a React component that renders an SVG, rather than its filename.
Hope this helps!
My bad I am sorry. Thanks.
FWIW, Currently, this issue was the first place I found a code example to get things working. The new CRA site + thinned out README had me lost.
I can now see it's all at https://facebook.github.io/create-react-app/docs/adding-images-fonts-and-files. Maybe since it wasn't searchable from the initial page, I moved on to try and find my solution elsewhere. That was a nice thing about the monolithic README.
Most helpful comment
You wrote:
The User Guide says:
Hope this helps!