I am trying to create a logo to use with the navbar on my react app using react bootstrap, and I have used the documentation as a guide. However, when viewing the page using localhost://3000, the following is shown:
What am I doing wrong? I have even tried copying the example code snippet from the documentation site into my project, and the same thing renders. However, I am open up the svg file with no issues within Chrome itself. Here is my code for App.js:
JavaScript
x
77
77
1
import React from 'react';
2
import './App.css';
3
import {
4
BrowserRouter as Router,
5
Switch,
6
Route,
7
Link
8
} from "react-router-dom";
9
import Container from 'react-bootstrap/Container'
10
import Navbar from 'react-bootstrap/Navbar';
11
import Nav from 'react-bootstrap/Nav';
12
13
class App extends React.Component {
14
constructor(props) {
15
super();
16
this.state = {
17
title: "Danny's Website",
18
headerLinks: [
19
{ title: 'Home', path: '/' },
20
{ title: 'Projects', path: '/projects' },
21
{ title: 'Documents', path: '/documents' },
22
{ title: 'Contact Me', path: '/contact' }
23
],
24
home: {
25
title: 'Hey there!',
26
subtitle: 'Welcome to my personal website.',
27
text: 'Placeholder text for now',
28
},
29
projects: {
30
title: 'My Projects',
31
subtitle: "From app development to tinkering with robots, I've tried it all",
32
},
33
documents: {
34
title: 'So you wanna see my deets, huh?',
35
},
36
contact: {
37
title: "Let's get in touch",
38
}
39
40
}
41
}
42
43
render() {
44
return (
45
<Router>
46
<Container fluid={true} className='p-0'> { /*Fluid false = Huge left margin. Change padding via "className='p-0'" */}
47
<Navbar expand="lg" bg="light" variant="light" className="border-bottom">
48
<Navbar.Brand href="#home" >
49
<img
50
alt=""
51
src="/bootstrap-solid.png"
52
width="30px"
53
height="30px"
54
className="d-inline-block align-top"/>{' '}
55
Home Site
56
</Navbar.Brand>
57
<Navbar.Toggle className="border-0" aria-controls="navbar-toggle" />
58
<Navbar.Collapse id="navbar-toggle">
59
<Nav className="ml-auto">
60
<Link className="nav-link" to="/">Home</Link>
61
<Link className="nav-link" to="/projects">Projects</Link>
62
<Link className="nav-link" to="/documents">Documents</Link>
63
<Link className="nav-link" to="/contact">Contact Me</Link>
64
</Nav>
65
</Navbar.Collapse>
66
</Navbar>
67
</Container>
68
</Router>
69
70
);
71
}
72
73
}
74
75
export default App;
76
77
Advertisement
Answer
User RK_oo7’s answer in the comments section is correct. The logo’s reference within the source code is correct, but the logo should be located within the public folder instead of src.