react-navigation / react-navigation/react-navigation.github.io
The documentation on type scripting nested navigation is unclear
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 324
- Fork
- 2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Current Behavior
- What code are you running and what is happening?
- Include a screenshot or video if it makes sense.
I'm trying to setup typescript for navigating into a nested navigator. From reading the doc, this was my attempt (which I'm assuming is wrong. It gives me''Create Conversation modal'' is referenced directly or indirectly in its own type annotation.ts(2502.
export type RootStackParamList = {
Home: undefined;
SignInUpTunnel: undefined;
'Create Conversation modal': NavigatorScreenParams<EditConversationModalNavigatorParamList>; <==== typescript error here
};
...
return
<AuthenticatedUserProvider>
<Stack.Navigator screenOptions={{ headerShown: false }} mode="modal">
<Stack.Screen name="Home" component={HomeDrawerNavigator} />
<Stack.Screen name="Create Conversation modal" component={EditConversationModalNavigator} />
</Stack.Navigator>
</AuthenticatedUserProvider>
...
export type EditConversationModalNavigatorParamList = RootStackParamList & {
'Create conversation': { userToInvite: UserConversationStatusCellData | null };
};
...
navigation.navigate('Create Conversation modal', { screen: 'Create conversation', params: { userToInvite } });
Unfortunately, the documentation on this topic is very thin: https://reactnavigation.org/docs/typescript#type-checking-screens-and-params-in-nested-navigator.
Also, the documentation uses a different navigation structure than the documentation for nesting navigators. making it hard to know where to actually put the NavigatorScreenParams and what paramList to give it.
Expected Behavior
I would expect the documentation for the typescripting of a nested navigator to include a full example (with the root navigator and nested navigator) and I would expect it to use the same navigators as the documentation to nest navigator.
How to reproduce
- You must provide a way to reproduce the problem. If you are having an issue with your machine or build tools, the issue belongs on another repository as that is outside of the scope of React Navigation.
- Either re-create the bug on Snack or link to a GitHub repository with code that reproduces the bug.
- Explain how to run the example app and any steps that we need to take to reproduce the issue from the example app.
- Keep the repro code as simple as possible, with the minimum amount of code required to repro the issue.
- Before reporting an issue, make sure you are on the latest version of the package.
Your Environment
| software | version |
|---|---|
| typescript 4.0.7 | |
| @react-navigation/native 5.9.3 | |
| react-native | |
| expo 40 | |
| node 14.6.0 | |
| npm or yarn 1.22.10 |
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với trang TypeScript về điều hướng lồng nhau và tài liệu riêng về việc lồng navigator được liên kết trong issue. So sánh cấu trúc navigator của chúng và sử dụng RootStackParamList cùng EditConversationModalNavigatorParamList được nêu làm ngữ cảnh ví dụ. Được xem là hoàn thành khi trang TypeScript bao gồm một ví dụ đầy đủ, tương ứng về root navigator và nested navigator, giải thích NavigatorScreenParams thuộc về đâu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- react-native, typescript
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100