首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >getUserConfirmation无法正常工作react native

getUserConfirmation无法正常工作react native
EN

Stack Overflow用户
提问于 2018-07-07 20:22:29
回答 1查看 143关注 0票数 0

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

代码语言:javascript
复制
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>
EN

回答 1

Stack Overflow用户

发布于 2018-07-29 22:25:25

虽然我没有从reacttraining.com中找到合适的例子,但在花了一些时间之后,我找到了一种方法。

代码语言:javascript
复制
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>

我们需要附加组件。因为我需要所有路由的身份验证when={true}。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51223186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档