Want to import images in React.js with styled-components? You should import images in the following manner (assuming that you have webpack configured for importing media assets.
1 2 3 4 5 6 7 | import myImage from '../../assets/image.png'; /* ... */ const HeaderImage = styled.div` background-image: url(${myImage}); `; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.