react-native-router-flux禁用android后退按钮返回登录界面

MCM*_*tan 3 android react-native react-native-router-flux

使用react-native-router-flux,在用户成功登录后,我想禁用后退按钮返回登录屏幕.但我似乎找不到获取当前"场景"或"堆栈"的方法,然后进行一些登录:

backAndroidHandler={() => {
                        if (currentScene === afterLoginScreeen) {
                         return true;   
                        }
                    }}
Run Code Online (Sandbox Code Playgroud)

有没有人设法处理这个问题?

bun*_*uth 15

正如我在react-native-router-flux上的经验一样

在Scene中键入= {ActionConst.RESET}

<Scene duration={0} key="main" component={Main} title="Some Title" type={ActionConst.RESET} />
Run Code Online (Sandbox Code Playgroud)

它应该是你需要避免返回登录屏幕

ActionConst和Scene.type解释

  • 仅当组件已在堆栈中时这才有效。如果没有它会抛出一个错误 (2认同)