React
useRef 用于返回一个可变的 ref 对象,其 .current 属性被初始化为传入的参数(initialValue)
useRef 创建的 ref 对象就是一个普通的 JavaScript 对象,而 useRef() 和自建一个 {current: ...} 对象的唯一区别是,useRef 会在每次渲染时返回同一个 ref 对象
const refContainer = useRef(initialValue);useRef 用于返回一个可变的 ref 对象,其 .current 属性被初始化为传入的参数(initialValue)
useRef 创建的 ref 对象就是一个普通的 JavaScript 对象,而 useRef() 和自建一个 {current: ...} 对象的唯一区别是,useRef 会在每次渲染时返回同一个 ref 对象
const refContainer = useRef(initialValue);