【发布时间】:2020-05-28 14:38:17
【问题描述】:
我对@987654322@ 中的ref 有一点怀疑。
我需要将其添加到依赖项中吗?
const App = () => {
const ref = useRef();
useEffect(() => {
//do something about ref
}, []); //<-- ref is not here
}
上面的代码没有给出任何 eslint 警告。 ref 是否在依赖项中豁免?
【问题讨论】:
-
ref本身是引用稳定的,它指向ref.current的值是变化的。
标签: reactjs react-hooks ref use-effect