반응형
useEffect
-
[React] useRef, useEffectReact 2024. 1. 18. 08:00
useRef, useEffect useRef useRef returns a mutable ref object whose .current property is initialized to the passed argument (initialValue). The returned object will persist for the full lifetime of the component. 공식 홈페이지의 설명에 따르면 .current 속성이 전달된 인수로(initialValue) 초기화되는 변경 가능한 ref 객체를 반환하고, 반환된 객체는 컴포넌트의 전체 수명동안 유지된다고 함 이를 풀어서 설명하면 아래와 같음 useRef는 변경 가능한 객체를 반환함 반환 객체는 useRef 인자를 current라는 속성 안에 저..