React native React Native:navigation.setOptions在调用navigation.replace时不工作

React native React Native:navigation.setOptions在调用navigation.replace时不工作,react-native,navigation,react-navigation,stack-navigator,React Native,Navigation,React Navigation,Stack Navigator,目前,我有一个显示记录详细信息的屏幕,还有Previous和Next按钮,用于在不同的记录之间导航。我使用CardStyleInterpolators.forHorizontalIOS作为默认屏幕选项,因此动画在进入新屏幕时水平向左滑动 对于Next按钮,我可以使用导航。正常更换,动画效果非常好 const showNextSample = () => { let currentIndex = itemIdList.indexOf(currentId); let nextI

目前,我有一个显示记录详细信息的屏幕,还有
Previous
Next
按钮,用于在不同的记录之间导航。我使用
CardStyleInterpolators.forHorizontalIOS
作为默认屏幕选项,因此动画在进入新屏幕时水平向左滑动

对于
Next
按钮,我可以使用
导航。正常更换
,动画效果非常好

const showNextSample = () => {
    let currentIndex = itemIdList.indexOf(currentId);
    let nextIndex = (currentIndex + 1) % itemIdList.length;
    let nextId = itemIdList[nextIndex];
    navigation.replace('DataEntry', { ...route.params, sampleid: nextId });
}
对于
Previous
按钮,我想反转动画方向,因此我尝试设置
gestureDirection
。但是,更改屏幕时的方向仍然相同(其他功能和记录细节仍正常工作)


此处相同,在根位置设置手势方向时起作用,但在组件中不起作用此处相同,在根位置设置手势方向时起作用,但在组件中不起作用
const showPrevSample = () => {
    let currentIndex = itemIdList.indexOf(currentId);
    let prevIndex = currentIndex ? currentIndex - 1 : itemIdList.length - 1;
    let prevId = itemIdList[prevIndex];
    navigation.setOptions({ gestureDirection: 'horizontal-inverted' });
    navigation.replace('DataEntry', { ...route.params, sampleid: prevId }); //Animation Direction is still the same
}