-1

In my project, the navbar template is in the scr/components/NavBar/index.js folder and the logo is in the scr/img/logo.svg folder, but even with the correct path it is not finding? folder structure:

1

the logo search is in the tag:

<NavLogo to="/">
    <img src={require('../../img/logo.svg')} alt="logo"/>
</NavLogo>
import React, { Component } from "react";
import { FaBars } from 'react-icons/fa'
import {Nav,
    NavbarContainer,
    NavLogo,
    NavMenu,
    NavItem,
    NavLinks,
    MobileIcon
} from './NavbarComp.js';

export default class NavbarComp extends Component {
    render () {
        return (
            <div>
                <Nav>
                    <NavbarContainer>
                        <NavLogo to="/">
                            <img src={require('../../img/logo.svg')} alt="logo"/>
                        </NavLogo>
                        <MobileIcon>
                            <FaBars />
                        </MobileIcon>
                        <NavMenu>
                            <NavItem>
                                <NavLinks to="home">Home</NavLinks>
                                <NavLinks to="about">Sobre Nós</NavLinks>
                                <NavLinks to="services">Serviços</NavLinks>
                                <NavLinks to="partner">Parceiros</NavLinks>
                                <NavLinks to="contact">Contato</NavLinks>
                            </NavItem>
                        </NavMenu>
                    </NavbarContainer>
                </Nav>
            </div>
        );
    }
}
vimuth
  • 5,064
  • 33
  • 79
  • 116
  • Does this help answer your question? https://stackoverflow.com/a/68970886/8690857 – Drew Reese Aug 15 '22 at 23:27
  • 1
    Does this answer your question? [Custom SVG is not loading in my image tag](https://stackoverflow.com/questions/68970722/custom-svg-is-not-loading-in-my-image-tag) – Vojin Purić Sep 06 '22 at 06:53

1 Answers1

0

My solution was:

import { ReactComponent as logo} from "./logo.svg";

<NavLogo to="/">
 <logo/>
</NavLogo>

As the example in StackOverFlow: https://stackoverflow.com/a/68970886/8690857