JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

react usePersistFn

发布时间 2023-03-22 21:16:38作者: 袜子破了
import {useRef,} from 'react';

function usePersistFn(fn) {
const fnRef = useRef(fn);
fnRef.current = fn;

const persistFn = useRef();
if (!persistFn.current) {
persistFn.current = function (...args) {
return fnRef.current.apply(this, args);
}
}

return persistFn.current;
}


export {
usePersistFn
}
    本栏目推荐文章
  • 2024-01-13 记录react-dnd拖拽组件的用法
  • 2024-01-13 react 监听上一页返回
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • 002*:React状态、属性、传值
  • react-native在windows环境搭建并使用脚手架新建工程
  • pm2启动react项目总是stopped
  • react 横向文字滚动动画 ,及纵向文字滚动动画带有间歇时间 交替渐变显示文字动画
  • 使用React构造前端应用
  • 关于REACT2024挑战赛
  • 使用nestjs和react快速搭建项目架子
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们