超出最大调用堆栈大小的 RN-Gesture-Handler 可滑动问题
RN-Gesture-Handler Swipeable issue with maximum call stack size exceeded
我无法使 Swipeable 组件与按钮一起使用。似乎它调用所有按钮来呈现我单击其中一个按钮的所有操作。知道这里出了什么问题吗?谢谢
import { RectButton, Swipeable } from 'react-native-gesture-handler';
....
cars.map((car: any, index: number) => {
if(car.is_cancellable) {
return(
<Swipeable
key={index}
renderRightActions={() => {
return(
<RectButton style={styles.swipeable} onPress={() => cancelOrder(car.uuid)}>
<Feather style={styles.icon} name="trash-2" size={32} color="white" />
</RectButton>
)
}}
rightThreshold={-300}
key={order.uuid}>
<TouchableOpacity onPress={() => selectOrder(car)}>
<PortfolioOrder car={car} />
</TouchableOpacity>
</Swipeable>
)
})
}})
const cancelOrder = (id: string) => {
console.log('press', id)
cancelOrder({id})
}
在记录同一条消息 100 多次后出现此错误
RangeError:超出最大调用堆栈大小
const cancelOrder = (id: string) => {
console.log('press', id)
cancelOrder({id})// this line is causing problem because of recursion.
}
我无法使 Swipeable 组件与按钮一起使用。似乎它调用所有按钮来呈现我单击其中一个按钮的所有操作。知道这里出了什么问题吗?谢谢
import { RectButton, Swipeable } from 'react-native-gesture-handler';
....
cars.map((car: any, index: number) => {
if(car.is_cancellable) {
return(
<Swipeable
key={index}
renderRightActions={() => {
return(
<RectButton style={styles.swipeable} onPress={() => cancelOrder(car.uuid)}>
<Feather style={styles.icon} name="trash-2" size={32} color="white" />
</RectButton>
)
}}
rightThreshold={-300}
key={order.uuid}>
<TouchableOpacity onPress={() => selectOrder(car)}>
<PortfolioOrder car={car} />
</TouchableOpacity>
</Swipeable>
)
})
}})
const cancelOrder = (id: string) => {
console.log('press', id)
cancelOrder({id})
}
在记录同一条消息 100 多次后出现此错误
RangeError:超出最大调用堆栈大小
const cancelOrder = (id: string) => {
console.log('press', id)
cancelOrder({id})// this line is causing problem because of recursion.
}