ray框架中,对下发dp的函数进行节流操作,不生效,请问如何解决呀

面板小程序开发相关产品技术讨论,包括面板小程序、智能小程序、React Native、Ray跨端框架、Panel SDK、微信小程序、小程序开发工具(IDE)及其他开发技术相关等话题


User avatar
TheThingX
Posts: 65
Location: TheThingX
Contact:

Muzzzhi 2022年 Oct 24日 15:29

React 函数式组件中使用防抖节流不生效, 需要通过useCallback返回一个缓存的函数。

Code: Select all

const handleClickDpPublish = useCallback(
    throttle(() => {
      if (!boolDpSchema) {
        return;
      }
      const dps = {
        [boolDpSchema.code]: !dpState[boolDpSchema.code],
      };
      setDpState(dps);
    }, 5000),
    []
  );

🏋️‍♀️🏋️‍♀️🏋️‍♀️🏋️‍♀️🏋️‍♀️

[][TheThingX.com]
Post Reply