Skip to content

Commit b786725

Browse files
committed
- Migrating to RN64
1 parent c98d52b commit b786725

34 files changed

+432
-868
lines changed

Example/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Windows files
2+
[*.bat]
3+
end_of_line = crlf

Example/.flowconfig

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
; Ignore polyfills
99
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; These should not be required directly
12-
; require from fbjs/lib instead: require('fbjs/lib/warning')
13-
node_modules/warning/.*
14-
1511
; Flow doesn't support platforms
1612
.*/Libraries/Utilities/LoadingView.js
1713

@@ -30,6 +26,8 @@ emoji=true
3026
esproposal.optional_chaining=enable
3127
esproposal.nullish_coalescing=enable
3228

29+
exact_by_default=true
30+
3331
module.file_ext=.js
3432
module.file_ext=.json
3533
module.file_ext=.ios.js
@@ -44,10 +42,6 @@ suppress_type=$FlowFixMe
4442
suppress_type=$FlowFixMeProps
4543
suppress_type=$FlowFixMeState
4644

47-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
49-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
50-
5145
[lints]
5246
sketchy-null-number=warn
5347
sketchy-null-mixed=warn
@@ -56,10 +50,8 @@ untyped-type-import=warn
5650
nonstrict-import=warn
5751
deprecated-type=warn
5852
unsafe-getters-setters=warn
59-
inexact-spread=warn
6053
unnecessary-invariant=warn
6154
signature-verification-failure=warn
62-
deprecated-utility=error
6355

6456
[strict]
6557
deprecated-type
@@ -71,4 +63,4 @@ untyped-import
7163
untyped-type-import
7264

7365
[version]
74-
^0.113.0
66+
^0.137.0

Example/.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
*.pbxproj -text
1+
# Windows files should use crlf line endings
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
*.bat text eol=crlf

Example/.prettierrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module.exports = {
33
jsxBracketSameLine: true,
44
singleQuote: true,
55
trailingComma: 'all',
6+
arrowParens: 'avoid',
67
};

Example/App.js

100755100644
Lines changed: 72 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,107 +4,94 @@
44
* @flow
55
*/
66

7-
import React, { Component } from 'react';
8-
import {
9-
Platform,
10-
StyleSheet,
11-
Text,
12-
View,
13-
TouchableOpacity
14-
} from 'react-native';
7+
import React, {Component} from 'react';
8+
import {Platform, StyleSheet, Text, View, TouchableOpacity} from 'react-native';
159

16-
import RNFileSelector from 'react-native-file-selector'
10+
import RNFileSelector from 'react-native-file-selector';
1711

18-
import RNFS from 'react-native-fs'
12+
import RNFS from 'react-native-fs';
1913

20-
import animatedPhoto from './assets/animated_photo.gif'
21-
import photo from './assets/photo.jpg'
14+
import animatedPhoto from './assets/animated_photo.gif';
15+
import photo from './assets/photo.jpg';
2216
// import info from './assets/nfo.plist'
2317

2418
export default class App extends Component<Props> {
25-
constructor (props) {
26-
super(props)
19+
constructor(props) {
20+
super(props);
2721

2822
this.state = {
29-
visible: false
30-
}
23+
visible: false,
24+
};
3125
}
3226

33-
_onPress () {
27+
_onPress() {
3428
let filter;
3529
if (Platform.OS === 'ios') {
3630
filter = [];
3731
} else if (Platform.OS === 'android') {
38-
filter = ".*\\.*";
32+
filter = '.*\\.*';
3933
}
4034

41-
42-
RNFileSelector.Show(
43-
{
44-
path: RNFS.DocumentDirectoryPath,
45-
filter: filter,
46-
title: 'Select File',
47-
closeMenu: true,
48-
editable: true,
49-
onDone: (path) => {
50-
console.log('file selected: ' + path)
51-
},
52-
onCancel: () => {
53-
console.log('cancelled')
54-
}
55-
}
56-
)
35+
RNFileSelector.Show({
36+
path: RNFS.DocumentDirectoryPath,
37+
filter: filter,
38+
title: 'Select File',
39+
closeMenu: true,
40+
editable: true,
41+
onDone: path => {
42+
console.log('file selected: ' + path);
43+
},
44+
onCancel: () => {
45+
console.log('cancelled');
46+
},
47+
});
5748
}
5849

59-
componentDidMount () {
60-
50+
componentDidMount() {
6151
// create a path you want to write to
62-
let animatedPhotoPath = RNFS.DocumentDirectoryPath + "/animated_photo.gif";
63-
let photoPath = RNFS.DocumentDirectoryPath + "/photo.jpg";
52+
let animatedPhotoPath = RNFS.DocumentDirectoryPath + '/animated_photo.gif';
53+
let photoPath = RNFS.DocumentDirectoryPath + '/photo.jpg';
6454
// let infoPath = RNFS.DocumentDirectoryPath + "/info.plist";
65-
let assetsPath = RNFS.DocumentDirectoryPath + '/assets'
55+
let assetsPath = RNFS.DocumentDirectoryPath + '/assets';
6656

6757
// write the file
68-
RNFS.writeFile(animatedPhotoPath, animatedPhoto, "utf8")
58+
RNFS.writeFile(animatedPhotoPath, animatedPhoto, 'utf8')
6959
.then(success => {
70-
console.log("FILE WRITTEN!");
60+
console.log('FILE WRITTEN!');
7161
})
7262
.catch(err => {
7363
console.log(err.message);
7464
});
7565

76-
RNFS.writeFile(photoPath, photo, "utf8")
66+
RNFS.writeFile(photoPath, photo, 'utf8')
7767
.then(success => {
78-
console.log("FILE WRITTEN!");
68+
console.log('FILE WRITTEN!');
7969
})
8070
.catch(err => {
8171
console.log(err.message);
8272
});
8373

84-
85-
RNFS.mkdir(assetsPath)
86-
.then(success => {
87-
console.log('DIRECTORY CREATED')
88-
89-
RNFS.writeFile(assetsPath + "/animated_photo.gif", animatedPhoto, "utf8")
90-
.then(success => {
91-
console.log("DIRECTORY WRITTEN!");
92-
})
93-
.catch(err => {
94-
console.log(err.message);
95-
});
96-
97-
RNFS.writeFile(assetsPath + "/photo.jpg", photo, "utf8")
98-
.then(success => {
99-
console.log("DIRECTORY WRITTEN!");
100-
})
101-
.catch(err => {
102-
console.log(err.message);
103-
});
104-
})
105-
106-
107-
// RNFS.writeFile(infoPath, info, "utf8")
74+
RNFS.mkdir(assetsPath).then(success => {
75+
console.log('DIRECTORY CREATED');
76+
77+
RNFS.writeFile(assetsPath + '/animated_photo.gif', animatedPhoto, 'utf8')
78+
.then(success => {
79+
console.log('DIRECTORY WRITTEN!');
80+
})
81+
.catch(err => {
82+
console.log(err.message);
83+
});
84+
85+
RNFS.writeFile(assetsPath + '/photo.jpg', photo, 'utf8')
86+
.then(success => {
87+
console.log('DIRECTORY WRITTEN!');
88+
})
89+
.catch(err => {
90+
console.log(err.message);
91+
});
92+
});
93+
94+
// RNFS.writeFile(infoPath, info, "utf8")
10895
// .then(success => {
10996
// console.log("FILE WRITTEN!");
11097
// })
@@ -114,20 +101,28 @@ export default class App extends Component<Props> {
114101
}
115102

116103
render() {
117-
return <View style={styles.container}>
118-
<TouchableOpacity onPress={() => {
119-
this._onPress()
104+
return (
105+
<View style={styles.container}>
106+
<TouchableOpacity
107+
onPress={() => {
108+
this._onPress();
120109

121110
// this.setState({ visible: true });
122111
}}>
123112
<Text>Click</Text>
124-
<RNFileSelector title={"Select File"} visible={this.state.visible} onDone={(path) => {
125-
console.log("file selected: " + path);
126-
}} onCancel={() => {
127-
console.log("cancelled");
128-
}}/>
113+
<RNFileSelector
114+
title={'Select File'}
115+
visible={this.state.visible}
116+
onDone={path => {
117+
console.log('file selected: ' + path);
118+
}}
119+
onCancel={() => {
120+
console.log('cancelled');
121+
}}
122+
/>
129123
</TouchableOpacity>
130-
</View>;
124+
</View>
125+
);
131126
}
132127
}
133128

@@ -137,5 +132,5 @@ const styles = StyleSheet.create({
137132
justifyContent: 'center',
138133
alignItems: 'center',
139134
backgroundColor: '#F5FCFF',
140-
}
135+
},
141136
});

Example/android/app/build.gradle

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.android.build.OutputFile
2020
* // default. Can be overridden with ENTRY_FILE environment variable.
2121
* entryFile: "index.android.js",
2222
*
23-
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
23+
* // https://reactnative.dev/docs/performance#enable-the-ram-format
2424
* bundleCommand: "ram-bundle",
2525
*
2626
* // whether to bundle JS and assets in debug mode
@@ -121,6 +121,8 @@ def jscFlavor = 'org.webkit:android-jsc:+'
121121
def enableHermes = project.ext.react.get("enableHermes", false);
122122

123123
android {
124+
ndkVersion rootProject.ext.ndkVersion
125+
124126
compileSdkVersion rootProject.ext.compileSdkVersion
125127

126128
compileOptions {
@@ -157,30 +159,24 @@ android {
157159
}
158160
release {
159161
// Caution! In production, you need to generate your own keystore file.
160-
// see https://facebook.github.io/react-native/docs/signed-apk-android.
162+
// see https://reactnative.dev/docs/signed-apk-android.
161163
signingConfig signingConfigs.debug
162164
minifyEnabled enableProguardInReleaseBuilds
163165
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
164166
}
165167
}
166168

167-
packagingOptions {
168-
pickFirst "lib/armeabi-v7a/libc++_shared.so"
169-
pickFirst "lib/arm64-v8a/libc++_shared.so"
170-
pickFirst "lib/x86/libc++_shared.so"
171-
pickFirst "lib/x86_64/libc++_shared.so"
172-
}
173-
174169
// applicationVariants are e.g. debug, release
175170
applicationVariants.all { variant ->
176171
variant.outputs.each { output ->
177172
// For each separate APK per architecture, set a unique version code as described here:
178173
// https://developer.android.com/studio/build/configure-apk-splits.html
174+
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
179175
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
180176
def abi = output.getFilter(OutputFile.ABI)
181177
if (abi != null) { // null for the universal-debug, universal-release variants
182178
output.versionCodeOverride =
183-
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
179+
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
184180
}
185181

186182
}
@@ -200,6 +196,7 @@ dependencies {
200196

201197
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
202198
exclude group:'com.facebook.flipper'
199+
exclude group:'com.squareup.okhttp3', module:'okhttp'
203200
}
204201

205202
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {

Example/android/app/src/debug/AndroidManifest.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)