-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prototype for static navigation config #11144
Conversation
Codecov ReportBase: 75.38% // Head: 74.33% // Decreases project coverage by
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## 7.x #11144 +/- ##
==========================================
- Coverage 75.38% 74.33% -1.06%
==========================================
Files 181 183 +2
Lines 5607 5688 +81
Branches 2208 2234 +26
==========================================
+ Hits 4227 4228 +1
- Misses 1329 1409 +80
Partials 51 51
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
The Expo app for the example from this branch is ready! |
c54d0ed
to
d896ace
Compare
9d21708
to
8259628
Compare
@satya164 will users be able to mix static and dynamic navigators in their setup? I am thinking about scenario when users start with basic static setup, but as the app grows bigger they find that they need to use dynamic nav in one particular navigator. |
@mdjastrzebski it'd be possible to use dynamic navigators inside static navigators but not vice-versa. |
Looks good to me! Will we also support this options callback behavior (its a classic 😂) const RootStack = createStackNavigator({
screens: {
Foo: {
options: ({ navigation }) => ({ ... }) |
@ericvicenti yup, it's the same as the dynamic version, so it can be an object or function that receives |
@satya164 I am curious:
|
|
c3dada4
to
0401900
Compare
11ecdc7
to
ba62d01
Compare
React Navigation 5+ has a dynamic API which makes it possible to achieve advanced use cases. But it can result in additional boilerplate and duplication. This is a prototype for a static API similar to React Navigation 4 to provide a simpler API for people who don't need dynamic configuration. This also intends to simplify 2 major issues: - Deep link configuration - TypeScript configuration ```js const HomeTabs = createBottomTabNavigator({ screenOptions: { tabBarActiveTintColor: "tomato" }, screens: { Groups: { screen: GroupsScreen, linking: "groups" }, Chat: { screen: ChatScreen, linking: "chat/:id" } } }); const RootStack = createStackNavigator({ screens: { Home: HomeTabs, Profile: ProfileScreen, Feed: { screen: FeedScreen, options: { headerTitle: "My Feed" } }, Settings: SettingsScreen } }); const Navigation = createStaticNavigation(RootStack); export default function App() { return ( <Navigation onStateChange={() => { // Do something }} /> ); } ``` - [Getting started](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-configuration.md) - [API reference](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-api-reference.md) - [TypeScript configuration](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-typescript.md) - [Authentication flow](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-authentication.md) - [Combining static and dynamic APIs](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-combine-with-dynamic.md)
React Navigation 5+ has a dynamic API which makes it possible to achieve advanced use cases. But it can result in additional boilerplate and duplication. This is a prototype for a static API similar to React Navigation 4 to provide a simpler API for people who don't need dynamic configuration. This also intends to simplify 2 major issues: - Deep link configuration - TypeScript configuration ```js const HomeTabs = createBottomTabNavigator({ screenOptions: { tabBarActiveTintColor: "tomato" }, screens: { Groups: { screen: GroupsScreen, linking: "groups" }, Chat: { screen: ChatScreen, linking: "chat/:id" } } }); const RootStack = createStackNavigator({ screens: { Home: HomeTabs, Profile: ProfileScreen, Feed: { screen: FeedScreen, options: { headerTitle: "My Feed" } }, Settings: SettingsScreen } }); const Navigation = createStaticNavigation(RootStack); export default function App() { return ( <Navigation onStateChange={() => { // Do something }} /> ); } ``` - [Getting started](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-configuration.md) - [API reference](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-api-reference.md) - [TypeScript configuration](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-typescript.md) - [Authentication flow](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-authentication.md) - [Combining static and dynamic APIs](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-combine-with-dynamic.md)
React Navigation 5+ has a dynamic API which makes it possible to achieve advanced use cases. But it can result in additional boilerplate and duplication. This is a prototype for a static API similar to React Navigation 4 to provide a simpler API for people who don't need dynamic configuration. This also intends to simplify 2 major issues: - Deep link configuration - TypeScript configuration ```js const HomeTabs = createBottomTabNavigator({ screenOptions: { tabBarActiveTintColor: "tomato" }, screens: { Groups: { screen: GroupsScreen, linking: "groups" }, Chat: { screen: ChatScreen, linking: "chat/:id" } } }); const RootStack = createStackNavigator({ screens: { Home: HomeTabs, Profile: ProfileScreen, Feed: { screen: FeedScreen, options: { headerTitle: "My Feed" } }, Settings: SettingsScreen } }); const Navigation = createStaticNavigation(RootStack); export default function App() { return ( <Navigation onStateChange={() => { // Do something }} /> ); } ``` - [Getting started](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-configuration.md) - [API reference](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-api-reference.md) - [TypeScript configuration](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-typescript.md) - [Authentication flow](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-authentication.md) - [Combining static and dynamic APIs](https://github.com/react-navigation/react-navigation.github.io/blob/main/versioned_docs/version-7.x/static-combine-with-dynamic.md)
Goal
React Navigation 5+ has a dynamic API which makes it possible to achieve advanced use cases. But it can result in additional boilerplate and duplication. This is a prototype for a static API similar to React Navigation 4 to provide a simpler API for people who don't need dynamic configuration.
This also intends to simplify 2 major issues:
API
Basic usage
Documentation
Potential TODOs
path
specifiedSupportgetComponent
for lazy requireAddlayout
/wrapper
option for custom UI and logic around the navigatorAdd ability pass dynamic data to use foroptions
if
option to conditionally render screens, e.g. for authenticationExact
in TS)Add helper to create a type for the navigation prop preserving navigator specific methods