react-navigation / react-navigation/react-navigation.github.io
NavigationContainer: initialRouteName: Issue with TypeScript
未关闭
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 324
- 派生
- 2k
- PR 合并指标
- 30 天内没有已合并 PR
描述
Summary
Following the documentation provided, I see that there is an issue when setting the property initialRouteName to the NavigationContainer tag.
Computer: Mac OS 14.1 (23B74)
Editor: VSCode using React Native Tools by Microsoft.
Description
package.json dependencies:
"dependencies": {
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"@react-navigation/stack": "^6.3.20",
"react": "18.2.0",
"react-native": "0.72.6",
"react-native-gesture-handler": "^2.13.4",
"react-native-safe-area-context": "^4.7.4",
"react-native-screens": "^3.27.0",
},
App.js:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Home from './views/Home'
const Stack = createNativeStackNavigator();
function App(): JSX.Element {
return (
<NavigationContainer initialRouteName="Home">
<Stack.Navigator>
<Stack.Screen name="Home" component={Home} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;
VSCode Error Popup:
Type '{ children: Element; initialRouteName: string; }' is not assignable to type 'IntrinsicAttributes & NavigationContainerProps & { theme?: Theme | undefined; linking?: LinkingOptions<RootParamList> | undefined; fallback?: ReactNode; documentTitle?: DocumentTitleOptions | undefined; onReady?: (() => void) | undefined; } & { ...; }'.
Property 'initialRouteName' does not exist on type 'IntrinsicAttributes & NavigationContainerProps & { theme?: Theme | undefined; linking?: LinkingOptions<RootParamList> | undefined; fallback?: ReactNode; documentTitle?: DocumentTitleOptions | undefined; onReady?: (() => void) | undefined; } & { ...; }'.ts(2322)
Screenshot:
Acceptance Criteria
I was expecting no error would show up
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的 Hello React Navigation 文档页面开始,检查使用 NavigationContainer 和 Stack.Navigator 的示例。使用所示的依赖项重现 TypeScript 错误,然后更新示例,使文档中的路由配置能够被接受且不再出现报告的错误。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- react-native, typescript
- 领域
- documentation, mobile-dev
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100