본문 바로가기

나의 FE피봇이야기/Type

[ Type / useRef ] 선언과 prop전달

error message

Type 'MutableRefObject<string>' is not assignable to type 'LegacyRef<HTMLInputElement> | undefined'.
Type 'MutableRefObject<string>' is not assignable to type 'RefObject<HTMLInputElement>'.
Types of property 'current' are incompatible.
Type 'string' is not assignable to type 'HTMLInputElement'.

'MutableRefObject<string>' 유형은 'LegacyRef<HTMLInputElement> | undefined' 유형에 할당할 수 없습니다.
'MutableRefObject<string>' 유형은 'RefObject<HTMLInputElement>' 유형에 할당할 수 없습니다.
'current' 속성 유형은 호환되지 않습니다.
'문자열' 유형은 'HTMLInputElement' 유형에 할당할 수 없습니다.

 

ref 선언

 

prop 전달

 

 

 

 

section ref

 

The error you're encountering is because the ref you're passing to the section element is of type MutableRefObject<HTMLElement | undefined>, but the ref prop expects a RefObject<HTMLElement>, where the current property is HTMLElement | null, not undefined.