Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
Module not found on images

I am new to react and try to create a slider. I want to create a slide which displays text and image on the same slide. Text display good but I can't success do display my image. I almost try everything I see in this forum but don't work.

data slider file

import React from 'react';
import one from "./img/first.png"

const dataSlider = [
    {
        id: 1,
        img: {one},
        title: "Summer sale",
        description: "Don't compromise on style! get flat 30% off for new arrivals",
        bg: "black",
    },
    {
        id: 2,
        img:{one},
        title: "Winter sale",
        description: "Don't compromise on style! get flat 30% off for new arrivals",
        bg: "red",
    },
    {
        id: 3,
        img:{one},
        title: "Popular sale",
        description: "Don't compromise on style! get flat 30% off for new arrivals",
        bg: "blue",
    },

];
export {dataSlider};

Slider.jsx

 <Arrow direction="left"  onClick={() => handleClick("left")}><ArrowLeftOutlined /></Arrow>
                <Wrapper>
                    {dataSlider.map(item =>(

                    <Slide bg={item.bg}>
                    <ImgContainer><Img  src={require( `${ item.img }` )} /></ImgContainer>
                    <InfoContainer><Title>{item.title}</Title><Description>{item.description}</Description><Button>shop now</Button></InfoContainer>
                    </Slide>

                    ))}

enter image description here

Error is: enter image description here

about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

Since you're using CRA. It would probably be easier to just add your images to the public folder.

Then in your dataSlider.js instead of importing the image, just do something like this:

{
  id: 1,
  img: "/img/first.png", // this will point to `/public/img/first.png` in the implementation
  title: "Summer sale",
  description: "Don't compromise on style! get flat 30% off for new arrivals",
  bg: "black",
},

And then in it's usage you would do this:

<img src={item.img} />
about 4 years ago · Santiago Gelvez Relatório

0

Your import one from "/img/first.jpg" points to the root of directory structure. Just remove the initial /.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda