-
Notifications
You must be signed in to change notification settings - Fork 21
[BPK-2295] Upgrade React Native to 0.59.0 #77
Conversation
@@ -202,6 +205,7 @@ | |||
D674D18120BEDBCA008F2E97 /* Frameworks */ = { | |||
isa = PBXGroup; | |||
children = ( | |||
60005AA122382F040076B576 /* JavaScriptCore.framework */, |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
.
63fde1f
to
982b89c
Compare
@@ -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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 🤓
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes a Jest issue:
"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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove a deprecation warning. See https://github.com/facebook/react-native/blob/d6236796b285e6ad19c53c5308a0ad9c10792a05/Libraries/ReactNative/UIManagerProperties.js#L15
onDateSelection={onChangeSelectedDates} | ||
selectedDates={selectedDates} | ||
selectedDates={selectedDates.map(parseDateToNative)} |
There was a problem hiding this comment.
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<*, *>> { |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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.
Tasks
package.json
of each componentIssues identified so far
testMatch: null
)> Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.
) (Fixed by doing this Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl. wix/react-native-navigation#4757 (comment))