Android getUserConfirmation无法正常工作

Android getUserConfirmation无法正常工作,android,react-native,react-router-native,Android,React Native,React Router Native,我打算使用“react router native”的getUserConfirmation向路由添加身份验证,但从未调用getUserConfirmation。我也找不到太多关于它的文档 const getConfirmation = (message, callback) => { //Here i will replace below code with authentication check Alert.alert('Confirm', message, [ {

我打算使用“react router native”的getUserConfirmation向路由添加身份验证,但从未调用getUserConfirmation。我也找不到太多关于它的文档

const getConfirmation = (message, callback) => {
  //Here i will replace below code with authentication check
  Alert.alert('Confirm', message, [
    { text: 'Cancel', onPress: () => callback(false) },
    { text: 'OK', onPress: () => callback(true) }
  ])
}

<NativeRouter getUserConfirmation={getConfirmation}>
......
</NativeRouter>
const getConfirmation=(消息,回调)=>{
//在这里,我将用身份验证检查替换下面的代码
警报。警报('Confirm',消息[
{text:'Cancel',onPress:()=>callback(false)},
{text:'OK',onPress:()=>回调(true)}
])
}
......

虽然我没有从中找到合适的例子,但花了一段时间后我找到了一种方法

const getConfirmation = (message, callback) => {
    // auth code to authenticate before entering route
    requireRouteAuth({props:{history}}, callback);
}

<NativeRouter getUserConfirmation={getConfirmation}>
    ......
    <Prompt when={true} message={location => "message"}/>
</NativeRouter>
const getConfirmation=(消息,回调)=>{
//进入路由前进行身份验证的身份验证代码
requireRouteAuth({props:{history}},回调);
}
......
“消息”}/>
我们需要附加组件。因为当={true}时,我需要对所有路由进行身份验证