Skip to content
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

[BPK-2295] Upgrade React Native to 0.59.0 #77

Merged
merged 13 commits into from Mar 18, 2019
Merged

Conversation

shaundon
Copy link
Contributor

@shaundon shaundon commented Mar 12, 2019

Tasks

  • Upgrade RN
  • Run on iOS
  • Run on Android
  • Confirm tests are ok
  • Upgrade Flow to align with RN 0.59.0's version
  • Go through each story and note anything broken (iOS)
  • Go through each story and note anything broken (Android)
  • Upgrade the React and RN versions in the package.json of each component

Issues identified so far

@shaundon shaundon marked this pull request as ready for review March 12, 2019 19:01
@@ -202,6 +205,7 @@
D674D18120BEDBCA008F2E97 /* Frameworks */ = {
isa = PBXGroup;
children = (
60005AA122382F040076B576 /* JavaScriptCore.framework */,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to manually link JavaScriptCore as mentioned in the 0.58.0 release notes:

if you are an iOS developer, you'll need to manually link JavaScriptCore.framework when upgrading;

"react": "16.6.3",
"react-dom": "16.6.3",
"react-native": "0.58.5",
"react-native-linear-gradient": "^2.5.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ColorPropType was deprecated in 0.58 so I upgraded react-native-linear-gradient to the latest version, which seems to fix the problem, and gets us back on a normal version and not this branch 🙌

@@ -56,6 +59,7 @@ const styles = StyleSheet.create({

export type Props = {
...$Exact<ImageProps>,
style: ViewStyleProp,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flow was giving us an error here because Image.style isn't quite the same as View.style, but we were using Image's style type here then applying it to a view (on line 144). So, I've made it explicitly use the style type from View.

@backpackbot
Copy link

backpackbot commented Mar 13, 2019

Warnings
⚠️

One or more packages have changed, but UNRELEASED.md wasn't updated.

⚠️

package-lock.json was updated. Ensure that this was intentional.

Generated by 🚫 dangerJS against 5e69dad

@shaundon shaundon changed the title [BPK-2295] Upgrade React Native to 0.58.5 [BPK-2295] Upgrade React Native to 0.59.0 Mar 13, 2019
@@ -24,7 +24,6 @@
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/react-native/flow-github/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed to fix this notice:

Screen Shot 2019-03-13 at 17 57 04

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also have a look at the .flowconfig of RN at 0.59.0? That might contain some new configuration that we should also add.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to do that, but if the config we have is already working for us, what is there to be gained by changing it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used that mentality previously, only to find out that we were missing out on a bunch of flow functionality.

In other words, when we aligned our version of flow to RN's version and subsequently aligned the .flowconfig, we found errors we were otherwise oblivious to.

Who knows, perhaps #77 (comment) goes away when we align the config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point! Let me investigate 🤓

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it based on RN's latest configs, no changes it seems (including #77 (comment) unfortunately) but as you say, good to be aligned with the latest and greatest.

@@ -49,6 +49,7 @@
"preset": "react-native",
"verbose": true,
"testRegex": ".*-test(\\.ios)?(\\.android)?\\.js$",
"testMatch": null,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes a Jest issue:

kulshekhar/ts-jest#756 (comment)

"babel-plugin-jest-hoist": "^23.2.0",
"@storybook/react-native": "^4.1.14",
"babel-jest": "^24.5.0",
"babel-plugin-jest-hoist": "^24.3.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated these to try and fix another issue but the upgrade doesn't seem to break anything so may as well do it.

"bpk-tokens": "^27.4.7",
"colors": "^1.3.3",
"danger": "^7.0.11",
"eslint-config-skyscanner-with-prettier": "^0.8.0",
"eslint-plugin-flowtype": "^3.2.0",
"eslint_d": "^7.2.0",
"flow-bin": "^0.78.0",
"flow-bin": "^0.92.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To align with RN 0.59's Flow version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: maybe this should explicitly be "0.92.0".

Fully appreciate that I probably set the carat last time haha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha - well I went with the carat because that's what RN does in their repo but I'm happy to lock it if you feel strongly about it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No lets follow them :)

@@ -9,7 +9,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.3.2'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix a build issue (see wix/react-native-navigation#4757 (comment))

},
"greenkeeper": {
"ignore": [
"flow-bin",
"react",
"react-dom",
"react-test-renderer",
"react-native",
"react-native-linear-gradient"
"react-native"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need to ignore linear gradient.

@@ -59,7 +70,7 @@ class BpkCalendar extends Component<Props, {}> {
const handle = findNodeHandle(this.calendarRef.current);
UIManager.dispatchViewManagerCommand(
handle,
UIManager.RCTBPKCalendar.Commands.forceRender,
UIManager.getViewManagerConfig('RCTBPKCalendar').Commands.forceRender,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onDateSelection={onChangeSelectedDates}
selectedDates={selectedDates}
selectedDates={selectedDates.map(parseDateToNative)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a nightmare issue to fix. Essentially something appears to have changed on the RN iOS side that means dates sent over the bridge weren't making it over properly, so it was failing to parse and causing red box errors.

I never figured out what exactly changed internally to make this happen, but I fixed it by taking inspiration from the Android version of this component and cast everything to a timestamp before sending it over the bridge, which makes it work.

return mutableListOf()
}

override fun createViewManagers(reactContext: ReactApplicationContext?): MutableList<ViewManager<*, *>> {
override fun createViewManagers(reactContext: ReactApplicationContext): MutableList<ViewManager<*, *>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After upgrading Gradly things I started seeing build errors here that we were failing to override the methods we were supposed to. I checked and it appears the signatures changed so that ReactApplicationContext is no longer optional. This change doesn't appear to break anything.

themeId: value,
theme: this.themes[value],
});
if (typeof value === 'string') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ridiculous check to stop Flow mithering me

@@ -21,6 +21,7 @@
import { type Node } from 'react';
import PropTypes from 'prop-types';
import { makeThemePropType } from 'react-native-bpk-theming';
import type { PressEvent } from 'react-native/Libraries/Types/CoreEventTypes';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you meant to use stuff like this? Isn't there a danger that they change what's exposed as it's not part of the official API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is that risk, but I don't see another way of doing it as it doesn't appear to be exported on the public interface, and if it breaks we'll find out as soon as we try to upgrade RN and can change it.

I did try this:

type TouchableProps = ElementProps<typeof TouchableWithoutFeedback>;
type TouchableOnPressProp = $PropertyType<TouchableProps, 'onPress'>;

But I get a Flow error and I couldn't figure it out:

Cannot instantiate $PropertyType because property onPress is missing in mixed [1].

     29│ } from './customPropTypes';
     30│
     31│ type TouchableProps = ElementProps<typeof TouchableWithoutFeedback>;
 [1] 32│ type TouchableOnPressProp = $PropertyType<TouchableProps, 'onPress'>;

@matthewdavidson may have an opinion as he's done similar things in his Flow-ing PRs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use SyntheticEvent<>, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't like that anymore, that's what we were using before this PR:

Screen Shot 2019-03-14 at 14 33 34

georgegillams
georgegillams previously approved these changes Mar 14, 2019
Copy link
Contributor

@matthewdavidson matthewdavidson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I manually tested each component across iOS & Android. Found one issue with the RN Switch component that Shaun already fixed (see facebook/react-native@d6ee448#diff-bb87898c3a651ca8f18771f770e8a808) but it'll have to wait until 59.2 to land.

@shaundon shaundon merged commit d7fc4f6 into master Mar 18, 2019
@shaundon shaundon deleted the BPK-2295-upgrade-rn branch March 18, 2019 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants