【发布时间】:2020-08-23 17:22:59
【问题描述】:
我已尝试根据react-navigation configuring links docs 为我的 react 本机应用程序编写配置对象。
我定义了一系列路径 --> 路由映射包括 Chat:'feed' 和 Explore:'news'
我的目标是让应用程序在解析https://example.com/someusername 时默认进入配置文件屏幕,并将“someusername”作为 id 参数传递。类似于https://instagram.com/apple 直接映射到@apple 帐户的配置文件屏幕。
const linking = {
prefixes: ['https://example.com', 'example://'],
config: {
Home: {
path: '',
screens: {
Chat: 'feed',
Explore: 'news',
Profile: ':id',
},
},
},
}
我不允许用户创建@feed、@news 等帐户以避免冲突。如果“someusername”尚不存在,我也会显示“未找到用户”消息
有没有正确的方法来做这个配置对象?或者如果我需要编写自定义的 getStateFromPath / getPathFromState 函数,有人有例子吗?
【问题讨论】:
标签: android ios react-native react-navigation deep-linking