我正在优化应用程序的性能,我想知道是否对那些不依赖于任何变量的函数使用useCallback钩子。on a variable outside this function scope. return someVar;这个函数不依赖于任何变量,所以我们可以用一个空数组将它封装在useCallback中: let someVar = "someVal";}, []);
现在
我发现他们使用的‘useCallback’和我使用的不同。下面是代码部分。我仍然认为这段代码与直接使用"useCallback“没有什么区别。// Saves incoming handler to the ref in order to avoid "useCallback hell" callbackRef.