Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cant't find a path for the image React styled components

I cant’t find a path for the image React styled components. The path is correct I think, could it be the styled-components issue ?
https://codesandbox.io/s/soirees-ll0ehp?file=/src/App.js:120-698

import styled from "styled-components";

export default function App() {
  const Main = styled.div`
    height: 100vh;
    background: center / cover no-repeat url("./assets/main.jpg");
    background-color: grey;
    background-image: url("../src/assets/main.jpg");
  `;
  const FindPicsWrapper = styled.div`
    position: absolute;
    top: 60vh;
    left: 50%;
    transform: translateX(-50%);
  `;
  return (
    <div className="App">
      <Main>
        <Header />
        <FindPicsWrapper>
          <FindPics />
        </FindPicsWrapper>
      </Main>
    </div>
  );
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

you have to use:

import img from './assets/main.jpg';

then use it as:

url(${img})

Edit Soirees (forked)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading