We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { useMemoizedFn } from 'ahooks'; import { useCallback } from 'react'; const fn = () => {}; fn.childVar = 'childVar'; fn.childFn = () => {}; const Demo: React.FC = () => { console.dir(fn); console.dir(useMemoizedFn(fn)); console.dir(useCallback(fn, [])); return <></>; }; export default Demo;
The text was updated successfully, but these errors were encountered:
useMemoizedFn 返回的是与传入的 fn 完全不同的一个新函数(只是在这个新函数里调用了传入的 fn),并一直保持这个新函数的引用。
所以,经过 useMemoizedFn 包裹的 fn,就不再是原来的 fn 了。
Sorry, something went wrong.
需要在函数上加一些自定义属性的话,这个场景 useMemoizedFn 目前满足不了,还是使用 useCallback 吧。
后面我在文档里说明这一点。
Successfully merging a pull request may close this issue.
The text was updated successfully, but these errors were encountered: