![](/img/trans.png)
[英]React Native passing Component/Object property to OnPress function
[英]Passing a memoized function to onPress of a component issue
假設我有以下組件:
<TouchableOpacity
style={...}
onPress={() => func(x)}
>
<TouchableOpacity/>
和 func() 定義如下:
const func = (x) => {console.log("help please")}
這項工作應該如此。 但是,一旦我將 func() 記憶如下:
const func = useMemo(()=>throttle(500,true, (x)=>{console.log("help please")}
我收到以下錯誤:
TypeError: callback.apply is not a function. (In 'callback.apply(self, arguments_)', 'callback.apply' is undefined)
注意:油門是進口的:
import { throttle } from "throttle-debounce";
嘗試刪除true
的參數,因為它沒有在文檔中指定
throttle(500, (x)=>{console.log("help please")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.