
<ProfileImg src={image} alt='프로필 이미지' onClick={clickProfile} />
<ImgInput type='file' accept='image/*' onChange={saveImage} ref={fileInput} />


useRef를 사용하면 파라미터로 들어온 초기값으로 초기화된 레퍼런스 객체를 반환한다. 만약 초기값이 null이라면 .current의 값이 null({ current: null })인 레퍼런스 객체가 반환된다.
그런데 current를 읽어올 때 null 체크를 해주지 않았다.
?.를 사용하여 문제를 해결 할 수 있었다. const clickProfile = () => {
fileInput.current?.click();
};
참고