Trusted answers to developer questions
Free System Design Interview Course
Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.
Logos are important in every website. They give your website an identity. We can add logos to our website using one of following methods:
The
import
keyword methodThe
path
method
The import
keyword method
In this method, we place the logo in a different folder with anyname. In our case, we named it images
. We use the import
keyword to reference the folder containing the logo.
Coding example
Let’s look at a coding example to learn more about this:
Adding logo using import keywordconst reportWebVitals = onPerfEntry => { if (onPerfEntry && onPerfEntry instanceof Function) { import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { getCLS(onPerfEntry); getFID(onPerfEntry); getFCP(onPerfEntry); getLCP(onPerfEntry); getTTFB(onPerfEntry); }); }};export default reportWebVitals;
Explanation
Line 1: We import the logo from
images
folder usingimport
keyword.Line 2: We import the
App.css
file for the styling.Line 10: We add the
img
tag, we called our logo using thesrc
attribute, and fix its height and width of100px
.
The path
method
In this method, we place the logo in a different folder with anyname. In our case, we named it images
. We will call the logo by providing its complete path in the src
attribute of the img
tag.
Coding example
Let’s look at a coding example to learn more about this:
Adding logo using path methodconst reportWebVitals = onPerfEntry => { if (onPerfEntry && onPerfEntry instanceof Function) { import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { getCLS(onPerfEntry); getFID(onPerfEntry); getFCP(onPerfEntry); getLCP(onPerfEntry); getTTFB(onPerfEntry); }); }};export default reportWebVitals;
Explanation
We first create an
images
folder inside ourpublic
folder.Line 1: we import the
App.css
file for the styling.Line 2: We add the
img
tag, provide the path of the logo in thesrc
attribute, and fix its height and width of100px
.
We have successfully added a logo to our React project.
RELATED TAGS
react
javascript
CONTRIBUTOR
Ukaoha Chizoba
Keep Exploring
Related Courses
TRENDING TOPICS
Copyright ©2024 Educative, Inc. All rights reserved.
Did you find this helpful?