I have the following code:
import styled from "styled-components";
import avatar from './assets/images/2020-avatar.png'
function App() {
return (
<Container>
<Avatar src={avatar} />
<Medium src={require("./assets/images/medium_512.png")} />
</Container>
);
}
const Container = styled.div`
position: relative;
display: flex;
`;
;
const Avatar = styled.img`
top: 120px;
width: 200px;
height: 200px;
position: absolute;
left: 583px;
object-fit: contain;
`;
const Medium = styled.img`
top: 475px;
left: 475px;
width: 150px;
height: 150px;
position: absolute;
object-fit: contain;
`;
export default App;
All of the references I've seen regarding the require()
statement should work for the medium_512.png
image, but it shows as a broken image. Only the imported avatar
image works.
Wondering what I'm doing wrong here and why all the examples I've seen using require I have similar syntax, but obviously something is wrong.