Skip to content

Commit

Permalink
deps: Remove react-navigation-tabs.
Browse files Browse the repository at this point in the history
See the previous commit for the reason for the $FlowFixMe.

In 0d2066f, we followed a warning to use the `react-native-tabs`
package:

```
console.warn node_modules/react-navigation/src/react-navigation.js:180
  TabBarBottom is deprecated. Please use the react-navigation-tabs package
  instead: https://github.com/react-navigation/react-navigation-tabs
```

An important bit of context that's missing from this warning is that
`react-navigation-tabs`'s function `createBottomTabNavigator`,
specifically, is what replaces what was previously done with
`TabBarBottom`.

`react-navigation` also exports another function
`createBottomTabNavigator`. So, is it so important to use the export
from `react-navigation-tabs`?

Turns out it's not; that function in `react-navigation` is an
extremely thin wrapper on the one in `react-navigation-tabs`:

In node_modules/react-navigation/src/react-navigation.js:69:
```
get createBottomTabNavigator() {
  return require('react-navigation-tabs').createBottomTabNavigator;
},
```

So, `react-navigation` depends on `react-navigation-tabs`, so we can
remove the latter as a direct dependency in our project.

The `react-navigation` v2 doc [1] also doesn't say anything about
needing to depend directly on `react-navigation-tabs`. See also
further discussion [2].

It would also have been possible to remove the direct dependency on
`react-native-screens`, but we're planning to use that later; that's
issue #4111.

The same story applies to `createMaterialTopTabNavigator`.

[1]: https://reactnavigation.org/docs/2.x/tab-based-navigation/
[2]: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/iOS.3A.20r-n-screens.20.2F.20r-n-document-picker/near/877185
  • Loading branch information
chrisbobbe committed May 20, 2020
1 parent 384583c commit c0c50d5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"react-native-webview": "^5.0.0",
"react-navigation": "^2.18.3",
"react-navigation-redux-helpers": "^2.0.9",
"react-navigation-tabs": "0.8.4",
"react-redux": "^5.0.7",
"react-test-renderer": "16.8.3",
"redux": "^4.0.0",
Expand Down
5 changes: 2 additions & 3 deletions src/main/MainTabs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @flow strict-local */
import React from 'react';
import { Platform } from 'react-native';
import { createBottomTabNavigator } from 'react-navigation-tabs';
import { createBottomTabNavigator } from 'react-navigation';

import type { TabNavigationOptionsPropsType } from '../types';
import tabsOptions from '../styles/tabs';
Expand All @@ -15,8 +15,7 @@ import IconUnreadConversations from '../nav/IconUnreadConversations';
import ProfileCard from '../account-info/ProfileCard';

export default createBottomTabNavigator(
// In the next commit, we'll activate this.
// £FlowFixMe `navigation` prop untyped on HomeTab, etc.
// $FlowFixMe `navigation` prop untyped on HomeTab, etc.
{
home: {
screen: HomeTab,
Expand Down
5 changes: 2 additions & 3 deletions src/main/StreamTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from 'react';
import { StyleSheet, Text } from 'react-native';
import { FormattedMessage } from 'react-intl';
import { createMaterialTopTabNavigator } from 'react-navigation-tabs';
import { createMaterialTopTabNavigator } from 'react-navigation';

import type { TabNavigationOptionsPropsType } from '../types';
import tabsOptions from '../styles/tabs';
Expand All @@ -17,8 +17,7 @@ const styles = StyleSheet.create({
});

export default createMaterialTopTabNavigator(
// In the next commit, we'll activate this.
// £FlowFixMe `navigation` prop untyped on SubscriptionsCard, etc.
// $FlowFixMe `navigation` prop untyped on SubscriptionsCard, etc.
{
subscribed: {
screen: SubscriptionsCard,
Expand Down

0 comments on commit c0c50d5

Please sign in to comment.