이미지 로딩이 안된다.
import profileDefaultImg from '../../assets/profileDefaultImg.png';
const Profile = () => {
return (
<div>
<img src={profileDefaultImg} alt="user profile picture" />
</div>
)
}
해결
import Image from 'next/image';
import profileDefaultImg from '../../assets/profileDefaultImg.png';
const Profile = () => {
return (
<>
<Image src={profileDefaultImg} alt="user profile picture" />
</>
)
}
Next.js의 Image 컴포넌트의 특징은 정적으로 임포트 된 이미지에 대해서는 width, height, blurDataURL 정보가 자동으로 생성
페이지가 100% 로드되지 않았을 때 이미지의 위치가 변하는 현상 즉, Cummulative Layout Shift(CLS) 같은 상황이 발생할 때 유용
'What I Learnd > TIL' 카테고리의 다른 글
TIL - supabase 외래키로 연결된 데이터 불러오기 (0) | 2023.08.25 |
---|---|
TIL - map 함수는 배열에서만 사용 가능하다! (0) | 2023.08.25 |
TIL - 특정파일 커밋 히스토리 삭제하기 [git] (0) | 2023.08.23 |
TIL - supabase 이메일 로그인 (0) | 2023.08.22 |
TIL - Next.js 설치 및 기능 알아보기 1 (0) | 2023.08.17 |