今天使用 React 的 ref 可能有点令人困惑。回到类组件的时代,文档中已经非常清楚了。
我们应该主要对DOM 元素使用 refs :
https://reactjs.org/docs/refs-and-the-dom.html
但今天我们把钩子和功能组件结合在一起。我们正在使用useRef钩子。
此外,这也给我们带来了新的模式。使用 ref 包含回调,或任何我们想要保留的数据(某种状态),但不需要重新渲染。它是一个强大的 API,也出现在文档中:
https://reactjs.org/docs/hooks-faq.html#is-there-something-like-instance-variables
所以现在 ref 可用于:
存储可变数据
记忆化的种类
但这些文档相互矛盾。并导致许多错误和开发团队的冲突。
医生说了两件事,这是一个问题。
那么,在这种情况下,“正确”的做法是什么?
const MyComponent = (props) => {
const [myMap1, _] = useState(new Map()); // 1.
const myMap2 = useMemo(()=> new Map(), []); // 2.
const myMap3 = useRef(new Map()); // 3.
...
};
Run Code Online (Sandbox Code Playgroud) 我找不到任何选项或命令来将文件或文件夹从我的 Visual Studio 项目中排除。(csproj、jsproj ...)
可以选择在解决方案资源管理器中包含文件和文件夹 -> 显示所有文件 ->在目标上单击鼠标左键-> 包含在项目中。
但没有排除的选项...
我用的是VS 2015。
我注意到 VS 2008 和 2010 中提供了排除选项。通过此文档:
https://msdn.microsoft.com/en-us/library/0ebzhwsk(v=vs.100).aspx
有什么解决办法吗?
谢谢
编辑:
问题仅出现在jsproj类型的项目中(例如 Apache Cordova 项目)。Exuding 在csproj中运行得很好。
javascript c# csproj visual-studio-cordova visual-studio-2015
我收到了这三个错误.没有网络断开连接.
(Eclipse经典4.2胜7终极x64)
查看这些错误,您是否能够知道安装失败的原因?
Downloading ICS_R1, Android API 15, revision 3
Download finished with wrong size. Expected 117308250 bytes, got 779 bytes.
Downloading XOOM2ME, Android API 13, revision 2
Download finished with wrong size. Expected 122780710 bytes, got 779 bytes.
Downloading XOOM2, Android API 13, revision 2
Download finished with wrong size. Expected 123990783 bytes, got 779 bytes.
Downloading XOOM, Android API 11, revision 2
Download finished with wrong size. Expected 1785905 bytes, got 779 bytes.
Downloading ADMIRAL, Android API 10, …Run Code Online (Sandbox Code Playgroud) javascript ×2
android ×1
c# ×1
csproj ×1
eclipse ×1
memoization ×1
react-hooks ×1
reactjs ×1
sdk ×1
windows ×1