在浏览 React 文档时,我遇到了 Refs。我想知道为什么使用 Refs,使用它们的目的是什么。我之前没有在之前的项目中使用过它们。有些人建议避免使用 Refs,我不知道为什么。
最佳答案
这里有一个很好的解释:https://facebook.github.io/react/docs/refs-and-the-dom.html
There are a few good use cases for refs:
Managing focus, text selection, or media playback.
Triggering imperative animations.
Integrating with third-party DOM libraries.
Avoid using refs for anything that can be done declaratively.
关于javascript - React 或 React-Native 中的 Refs 是什么以及使用它们的重要性是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46475921/