From 7f19e3d8ec46a46dddb66a95e34ec3ce2358f79e Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Wed, 20 Jun 2018 19:49:54 +0300 Subject: [PATCH] navigation: Upgrade to React Navigation v2 Upgrade to React Navigation 2 and do the minimal changes that make our code compatible. Navigating behavior has changed, and pushing a route with the same key does not result in duplicated entry in the history. Fixes #2682 The code to wire RN navigator to Redux have changed. The newer approach is simpler, just using `reduxifyNavigator` helper does most of the work. --- .eslintrc.yaml | 2 +- package.json | 4 +- src/nav/AppWithNavigation.js | 32 ++-------- yarn.lock | 115 ++++++++++++++++++++++++++++++----- 4 files changed, 107 insertions(+), 46 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index d770e44266e..4e2b0e8a578 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -112,7 +112,7 @@ rules: allen, jan, donald, jane, unicode, joe, unescape, dan, abramov, lang, bool, ionicons, truthy, bezier, decrement, js, oauth, jsonp, otp, Otp, ascii, Ascii, substr, Util, actionsheet, unmute, mfrac, otp, Otp, ascii, Ascii, substr, Util, - actionsheet, jsonp, actionsheet, ionicons, denmark, copenhagen, unregister, + actionsheet, jsonp, actionsheet, ionicons, denmark, copenhagen, unregister, reduxify, gcm, unstarMessage, Unstar, wildcard_mentioned, lightbox, resize, remobile, tz, multiline, uniqby, zoe, localizable, appid, apns, Entypo, msup, mrow, webview, js, timerow, reselect, addons, cancelable, gravatar_hash, pms, msgs, collapsable, diff --git a/package.json b/package.json index 1347a162baf..45c1b7ab026 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,8 @@ "react-native-sound": "^0.10.9", "react-native-text-input-reset": "^1.0.2", "react-native-vector-icons": "^4.6.0", - "react-navigation": "^1.5.12", - "react-navigation-redux-helpers": "^1.1.1", + "react-navigation": "^2.6.0", + "react-navigation-redux-helpers": "^2.0.2", "react-redux": "^5.0.7", "react-test-renderer": "16.3.2", "redux": "^4.0.0", diff --git a/src/nav/AppWithNavigation.js b/src/nav/AppWithNavigation.js index 15f7fb35a27..72660d6604c 100644 --- a/src/nav/AppWithNavigation.js +++ b/src/nav/AppWithNavigation.js @@ -1,36 +1,12 @@ /* @flow */ import { connect } from 'react-redux'; +import { reduxifyNavigator } from 'react-navigation-redux-helpers'; -import React, { PureComponent } from 'react'; -import { addNavigationHelpers } from 'react-navigation'; -import { createReduxBoundAddListener } from 'react-navigation-redux-helpers'; - -import type { Dispatch } from '../types'; import { getNav } from '../selectors'; import AppNavigator from './AppNavigator'; -type Props = { - dispatch: Dispatch, - nav: Object, -}; - -class AppWithNavigation extends PureComponent { - render() { - const { dispatch, nav } = this.props; - const addListener = createReduxBoundAddListener('root'); - - return ( - - ); - } -} +const App = reduxifyNavigator(AppNavigator, 'root'); export default connect(state => ({ - nav: getNav(state), -}))(AppWithNavigation); + state: getNav(state), +}))(App); diff --git a/yarn.lock b/yarn.lock index 961a4db2e8d..7165aa8c0a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1971,6 +1971,13 @@ create-react-class@^15.6.3: loose-envify "^1.3.1" object-assign "^4.1.1" +create-react-context@^0.2.1: + version "0.2.2" + resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.2.2.tgz#9836542f9aaa22868cd7d4a6f82667df38019dca" + dependencies: + fbjs "^0.8.0" + gud "^1.0.0" + cross-spawn@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" @@ -2066,6 +2073,10 @@ decamelize@^1.0.0, decamelize@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + decompress-response@^3.2.0: version "3.3.0" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" @@ -2742,6 +2753,18 @@ fbjs-scripts@^0.8.1: semver "^5.1.0" through2 "^2.0.0" +fbjs@^0.8.0: + version "0.8.17" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd" + dependencies: + core-js "^1.0.0" + isomorphic-fetch "^2.1.1" + loose-envify "^1.0.0" + object-assign "^4.1.0" + promise "^7.1.1" + setimmediate "^1.0.5" + ua-parser-js "^0.7.18" + fbjs@^0.8.14, fbjs@^0.8.16, fbjs@^0.8.9: version "0.8.16" resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db" @@ -3183,6 +3206,10 @@ growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" +gud@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0" + gulp-util@^3.0.4: version "3.0.8" resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" @@ -5852,6 +5879,13 @@ prop-types@^15.5.8, prop-types@^15.6.0: loose-envify "^1.3.1" object-assign "^4.1.1" +prop-types@^15.6.1: + version "15.6.2" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102" + dependencies: + loose-envify "^1.3.1" + object-assign "^4.1.1" + proxy-from-env@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" @@ -5884,6 +5918,13 @@ qs@~6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" +query-string@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.1.0.tgz#01e7d69f6a0940dac67a937d6c6325647aa4532a" + dependencies: + decode-uri-component "^0.2.0" + strict-uri-encode "^2.0.0" + querystringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.0.0.tgz#fa3ed6e68eb15159457c89b37bc6472833195755" @@ -5971,7 +6012,7 @@ react-is@^16.3.2: version "16.3.2" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.3.2.tgz#f4d3d0e2f5fbb6ac46450641eb2e25bf05d36b22" -react-lifecycles-compat@^3.0.2: +react-lifecycles-compat@^3, react-lifecycles-compat@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" @@ -6042,6 +6083,12 @@ react-native-safe-area-view@^0.7.0: dependencies: hoist-non-react-statics "^2.3.1" +react-native-safe-area-view@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/react-native-safe-area-view/-/react-native-safe-area-view-0.8.0.tgz#22d78cb8e8658d04a10cd53c1546e0bc86cb7aea" + dependencies: + hoist-non-react-statics "^2.3.1" + react-native-safe-area@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/react-native-safe-area/-/react-native-safe-area-0.4.1.tgz#9cf47734054d1f9b9b934a012ac1939a5bbe20ca" @@ -6061,12 +6108,18 @@ react-native-sound@^0.10.9: version "0.10.9" resolved "https://registry.yarnpkg.com/react-native-sound/-/react-native-sound-0.10.9.tgz#6b00b0f4afd017cde09fbb9d171df1b5d5b851a8" -"react-native-tab-view@github:react-navigation/react-native-tab-view": - version "0.0.74" - resolved "https://codeload.github.com/react-navigation/react-native-tab-view/tar.gz/36ebd834d78b841fc19778c966465d02fd1213bb" +react-native-tab-view@^0.0.77: + version "0.0.77" + resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-0.0.77.tgz#11ceb8e7c23100d07e628dc151b57797524d00d4" dependencies: prop-types "^15.6.0" +react-native-tab-view@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-1.0.2.tgz#66e0bc6d38a227ed2b212e3a256b7902f6ce02ed" + dependencies: + prop-types "^15.6.1" + react-native-text-input-reset@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/react-native-text-input-reset/-/react-native-text-input-reset-1.0.2.tgz#cfaa6d9b45da934e1725c01b1698f8a05591661c" @@ -6143,24 +6196,48 @@ react-native@^0.55.4: xmldoc "^0.4.0" yargs "^9.0.0" -react-navigation-redux-helpers@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/react-navigation-redux-helpers/-/react-navigation-redux-helpers-1.1.1.tgz#6832c831e3fa47fb030012fac8ebdf37e45bda9f" +react-navigation-deprecated-tab-navigator@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/react-navigation-deprecated-tab-navigator/-/react-navigation-deprecated-tab-navigator-1.3.0.tgz#015dcae1e977b984ca7e99245261c15439026bb7" + dependencies: + react-native-tab-view "^0.0.77" + +react-navigation-drawer@0.4.3: + version "0.4.3" + resolved "https://registry.yarnpkg.com/react-navigation-drawer/-/react-navigation-drawer-0.4.3.tgz#c04c94e2429b7e724801af05bd0a93a79cb27f71" + dependencies: + react-native-drawer-layout-polyfill "^1.3.2" + +react-navigation-redux-helpers@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/react-navigation-redux-helpers/-/react-navigation-redux-helpers-2.0.2.tgz#029cd5d0b50deabd2aa157afe1a2512ce205f541" dependencies: invariant "^2.2.2" -react-navigation@^1.5.12: - version "1.5.12" - resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-1.5.12.tgz#e226b4906c76dde55ddf7cc0a62ea04c77140d8a" +react-navigation-tabs@0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/react-navigation-tabs/-/react-navigation-tabs-0.5.1.tgz#ed33bce3a3e21b92646700de25bd94b8fc570371" + dependencies: + hoist-non-react-statics "^2.5.0" + prop-types "^15.6.1" + react-lifecycles-compat "^3.0.4" + react-native-safe-area-view "^0.7.0" + react-native-tab-view "^1.0.0" + +react-navigation@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-2.6.0.tgz#7734aec4acf690d556a5bdcbda10ea79a3dc6c7e" dependencies: clamp "^1.0.1" + create-react-context "^0.2.1" hoist-non-react-statics "^2.2.0" path-to-regexp "^1.7.0" - prop-types "^15.5.10" - react-lifecycles-compat "^3.0.2" - react-native-drawer-layout-polyfill "^1.3.2" - react-native-safe-area-view "^0.7.0" - react-native-tab-view "github:react-navigation/react-native-tab-view" + query-string "^6.1.0" + react-lifecycles-compat "^3" + react-native-safe-area-view "^0.8.0" + react-navigation-deprecated-tab-navigator "1.3.0" + react-navigation-drawer "0.4.3" + react-navigation-tabs "0.5.1" react-proxy@^1.1.7: version "1.1.8" @@ -6939,6 +7016,10 @@ stream@^0.0.2: dependencies: emitter-component "^1.1.1" +strict-uri-encode@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" + string-length@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac" @@ -7263,6 +7344,10 @@ typescript@^2.5.1: version "2.8.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170" +ua-parser-js@^0.7.18: + version "0.7.18" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed" + ua-parser-js@^0.7.9: version "0.7.14" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.14.tgz#110d53fa4c3f326c121292bbeac904d2e03387ca"