我正在尝试对使用反应导航5的我的React本机应用程序使用深层链接,并一直关注:https://reactnavigation.org/docs/configuring-links
这是我的代码:
...
const App = observer(() => {
const { NavTheme, themeLoaded } = useTheme();
const linking = {
prefixes: ['myurlhere://'],
config: {
screens: {
Confirmed: {
path: 'confirm'
}
}
}
};
return (
<NavigationContainer linking={linking} theme={NavTheme}>
<LoginStack.Navigator>
<LoginStack.Screen name="Login" component={Login} options={{ headerShown: false }}/>
<LoginStack.Screen name="Confirmed" component={Confirmed} options={{ headerShown: false }}/>
</LoginStack.Navigator>
</NavigationContainer>
);
});
当我去野生动物园并键入 myurlhere:// confirm 时,它将打开应用程序,然后显示以下错误:
console.error: "The action 'NAVIGATE' with payload {"name":"confirm","params":{}} was not handled by any navigator.
Do you have a screen named 'confirm'?
If you're trying to navigate to a screen in a nested navigator, see https://reactnavigation.org/docs/nesting-navigators#navigating-to-a-screen-in-a-nested-navigator.
我希望这可以导航到“我的确认路线”。我在做什么错了?
答案 0 :(得分:0)
我假设您使用的是旧版本的 react-navigation
尝试像这样更改您的配置对象
const linking = {
prefixes: ['myurlhere://'],
config: {
Confirmed: 'confirm'
}
};