我有一個問題: onSwipeableOpen 被立即呼叫,實際上沒有進行滑動。我的意思是,我做了這樣的事情:onSwipeableOpen={console.log(id)}
所以當我進入 Swipeable List 螢屏時,應用程式會立即列印所有行的 id ...
這是我的代碼:
const renderItems2 = ({index,item,section})=>{
const {title,theaddress,id} = item;
const swipeRight = (progress,dragX) =>{
const scale = dragX.interpolate({
inputRange:[-200,0],
outputRange:[1,0.5],
extrapolate:'clamp'
})
return(
<Animated.View style={{backgroundColor:'red',width:"60%",justifyContent:'center'}}>
<Animated.Text style={{marginLeft:'auto',marginRight:50, fontSize:15, fontWeight:'bold',transform:[{scale}]}}>Delete Item</Animated.Text>
</Animated.View>
)
}
return(
<Swipeable
renderRightActions={swipeRight}
rightThreshold={-200}
onSwipeableOpen={console.log(id)}
>
<Animated.View>
<WhiteAddressButton title={title} btnId={index} desc={theaddress} onPress={()=>alert("hey")} />
</Animated.View>
</Swipeable>
);
}
進入螢屏后,我立即獲得,無需任何觸發,無需任何滑動:
日志 2 日志 3 日志 5
請問有什么幫助嗎?
uj5u.com熱心網友回復:
onSwipeableOpen沒有立即呼叫,你需要傳遞函式的參考而不是傳遞console.log,試試這個,你會看到:
onSwipeableOpen={() => console.log(id)}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/433657.html
下一篇:我在reactnative中撰寫了應用程式,但AsyncStorage似乎無法正常作業。當我在手機上重新打開應用程式時,它不記得我之前輸入的內容
