React Hooks & useCallback & useMemo
React Hooks & useCallback & useMemo
https://reactjs.org/docs/hooks-reference.html#usecallback
bug
const [unmount, setUnmount] = useState(false);
const widthRef = useRef(null);
// useCallback()
const refClick = (isFirst = true) => {
const dom = ReactDOM.findDOMNode(widthRef.current);
const width = dom ? dom.getBoundingClientRect().width : 50;
return isFirst ? (width - 50) : width;
};
useEffect(() => {
if(!unmount) {
// refClick();
// useCallback(refClick);
}
return () => {
setUnmount(true);
};
}, [unmount,]);
// }, [unmount, refClick]);
refs
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/11818989.html
未经授权禁止转载,违者必究!