front-end/clone-coding
[React] 리액트 이미지 엑박일 때
행인데어
2022. 10. 25. 23:57
분명 이미지가 제대로 나왔었는데 오랜만에 실행해보니 이미지가 안뜸
구글링 해보니 해결책은
1. <img src={require("이미지경로").default} />
2. <img src={process.env.PUBLIC_URL + "이미지경로"} />
이렇게 두 가지가 있었는데 1번으로는 해결이 안됐고 2번을 적용하니 해결됐음!!
참고: https://create-react-app.dev/docs/using-the-public-folder/
Using the Public Folder | Create React App
Note: this feature is available with react-scripts@0.5.0 and higher.
create-react-app.dev