Skip to content

Commit aa926e3

Browse files
Lucas Bentofacebook-github-bot
Lucas Bento
authored andcommitted
Open links from new app screen in computer's browser (#24843)
Summary: This PR is related to #24760 and adds the `openURLInBrowser` functionality introduced on react-native-community/cli#383. [General] [Changed] - Open links from new app in computer's browser. Pull Request resolved: #24843 Reviewed By: rickhanlonii Differential Revision: D15334011 Pulled By: cpojer fbshipit-source-id: 947ad1b113923989cf706e60851e02a87e1099e8
1 parent 248a108 commit aa926e3

File tree

4 files changed

+85
-22
lines changed

4 files changed

+85
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow strict-local
9+
*/
10+
11+
'use strict';
12+
13+
const getDevServer = require('./getDevServer');
14+
15+
function openURLInBrowser(url: string) {
16+
fetch(getDevServer().url + 'open-url', {
17+
method: 'POST',
18+
body: JSON.stringify({url}),
19+
});
20+
}
21+
22+
module.exports = openURLInBrowser;

Libraries/NewAppScreen/components/LearnMoreLinks.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
'use strict';
1212

1313
import React from 'react';
14-
import {View, Text, StyleSheet, TouchableOpacity, Linking} from 'react-native';
14+
import {View, Text, StyleSheet, TouchableOpacity} from 'react-native';
15+
import openURLInBrowser from 'react-native/Libraries/Core/Devtools/openURLInBrowser';
1516
import Colors from './Colors';
1617

1718
const links = [
@@ -70,7 +71,7 @@ const LinkList = () => (
7071
<View style={styles.separator} />
7172
<TouchableOpacity
7273
accessibilityRole={'button'}
73-
onPress={() => Linking.openURL(item.link)}
74+
onPress={() => openURLInBrowser(item.link)}
7475
style={styles.linkContainer}>
7576
<Text style={styles.link}>{item.title}</Text>
7677
<Text style={styles.description}>{item.description}</Text>

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@
7979
},
8080
"dependencies": {
8181
"@babel/runtime": "^7.0.0",
82-
"@react-native-community/cli": "2.0.0-alpha.16",
83-
"@react-native-community/cli-platform-ios": "2.0.0-alpha.15",
82+
"@react-native-community/cli": "2.0.0-alpha.19",
8483
"@react-native-community/cli-platform-android": "2.0.0-alpha.15",
84+
"@react-native-community/cli-platform-ios": "2.0.0-alpha.15",
8585
"abort-controller": "^3.0.0",
8686
"art": "^0.10.0",
8787
"base64-js": "^1.1.2",

yarn.lock

+58-18
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@
10641064
"@types/istanbul-lib-coverage" "^2.0.0"
10651065
"@types/yargs" "^12.0.9"
10661066

1067-
"@react-native-community/[email protected]", "@react-native-community/cli-platform-android@^2.0.0-alpha.15":
1067+
"@react-native-community/[email protected]":
10681068
version "2.0.0-alpha.15"
10691069
resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-2.0.0-alpha.15.tgz#5ab64c68ee828c30e866923add5e1bab81c9102a"
10701070
integrity sha512-f5ogc1GxzkkDRw2o7PX+tnEDZ/uZYshf/5UaoH4qmaXhHdCulVSd24jTKH4HiRAXrbLf+3bm6JbwG4OLB09fzA==
@@ -1075,7 +1075,18 @@
10751075
slash "^2.0.0"
10761076
xmldoc "^0.4.0"
10771077

1078-
"@react-native-community/[email protected]", "@react-native-community/cli-platform-ios@^2.0.0-alpha.15":
1078+
"@react-native-community/cli-platform-android@^2.0.0-alpha.19":
1079+
version "2.0.0-alpha.19"
1080+
resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-2.0.0-alpha.19.tgz#367f08455561ea7f6d8646e01d5c9d3ca5de2e21"
1081+
integrity sha512-cfS9m6YaUmmNr7lwJy+tLUUgEBtC4fCfHli3gs0EeGUO972oIJ+DuFlNxjw1lI6Pdf2rOEP5H6lPD54LdAcvNQ==
1082+
dependencies:
1083+
"@react-native-community/cli-tools" "^2.0.0-alpha.19"
1084+
logkitty "^0.4.0"
1085+
node-fetch "^2.2.0"
1086+
slash "^2.0.0"
1087+
xmldoc "^0.4.0"
1088+
1089+
"@react-native-community/[email protected]":
10791090
version "2.0.0-alpha.15"
10801091
resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-2.0.0-alpha.15.tgz#959190650a1fafeae9bbabcc422329374918b466"
10811092
integrity sha512-gQKF9Y1dIqs2i5vveZVveUchUm0fw4bFw8XRmiy41yeb3/Qtyg8PCpnjGj+0fK7G5tW/23T6I2v4C1fRCRfnoQ==
@@ -1084,6 +1095,15 @@
10841095
chalk "^1.1.1"
10851096
xcode "^2.0.0"
10861097

1098+
"@react-native-community/cli-platform-ios@^2.0.0-alpha.19":
1099+
version "2.0.0-alpha.19"
1100+
resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-2.0.0-alpha.19.tgz#7d7777e026f1d281a558247aa04d0978c2181fb2"
1101+
integrity sha512-SRsLOTeI+DT+53K6lz5bNUvQyjB1eBeDKOwQppkuloHxaRH0E0f9w9IC4x3x0pofMQReW2IgiBpuD4EtORbU+w==
1102+
dependencies:
1103+
"@react-native-community/cli-tools" "^2.0.0-alpha.19"
1104+
chalk "^1.1.1"
1105+
xcode "^2.0.0"
1106+
10871107
"@react-native-community/cli-tools@^2.0.0-alpha.14":
10881108
version "2.0.0-alpha.14"
10891109
resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-2.0.0-alpha.14.tgz#c625fcc9d03d77428c242801510280ce88ef0e4b"
@@ -1093,15 +1113,25 @@
10931113
lodash "^4.17.5"
10941114
mime "^1.3.4"
10951115

1096-
"@react-native-community/cli@2.0.0-alpha.16":
1097-
version "2.0.0-alpha.16"
1098-
resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-2.0.0-alpha.16.tgz#3a69e3dcbc7914025784abd0c53a86248a14aa6d"
1099-
integrity sha512-AeJr5wgW7zvripzU8X3CK7fMItSAoVe3nv8fvyR2fP12nVp+MfnJCt2O+utq4DhCq2drrZObTuX+WboaUAXhbw==
1116+
"@react-native-community/cli-tools@^2.0.0-alpha.19":
1117+
version "2.0.0-alpha.19"
1118+
resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-2.0.0-alpha.19.tgz#0cdda92a3c51fb526407eb2106537a9197e4804c"
1119+
integrity sha512-HxiqTy6FtZBsxV4gZFM7YLmfpe4OEb8pNjfkpDC5OspzEG3VgMZlquuA5008/pQP7jrxBsKcoekrCBAxij+15g==
11001120
dependencies:
1101-
"@react-native-community/cli-platform-android" "^2.0.0-alpha.15"
1102-
"@react-native-community/cli-platform-ios" "^2.0.0-alpha.15"
1103-
"@react-native-community/cli-tools" "^2.0.0-alpha.14"
11041121
chalk "^1.1.1"
1122+
lodash "^4.17.5"
1123+
mime "^1.3.4"
1124+
1125+
"@react-native-community/[email protected]":
1126+
version "2.0.0-alpha.19"
1127+
resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-2.0.0-alpha.19.tgz#6be05d488a67d5a71647a172135e8f3722389320"
1128+
integrity sha512-1cJ6DY1heQGWaEQcyRm/xQXN8LXrCL71e3fZV43McIjqyONupQqgKjO3Pno9N8QT6S7mOsT9R2gv//ytHjwbxg==
1129+
dependencies:
1130+
"@react-native-community/cli-platform-android" "^2.0.0-alpha.19"
1131+
"@react-native-community/cli-platform-ios" "^2.0.0-alpha.19"
1132+
"@react-native-community/cli-tools" "^2.0.0-alpha.19"
1133+
chalk "^1.1.1"
1134+
command-exists "^1.2.8"
11051135
commander "^2.19.0"
11061136
compression "^1.7.1"
11071137
connect "^3.6.5"
@@ -1125,7 +1155,7 @@
11251155
morgan "^1.9.0"
11261156
node-fetch "^2.2.0"
11271157
node-notifier "^5.2.1"
1128-
opn "^3.0.2"
1158+
open "^6.2.0"
11291159
ora "^3.4.0"
11301160
plist "^3.0.0"
11311161
semver "^5.0.3"
@@ -2107,6 +2137,11 @@ [email protected], combined-stream@~1.0.6:
21072137
dependencies:
21082138
delayed-stream "~1.0.0"
21092139

2140+
command-exists@^1.2.8:
2141+
version "1.2.8"
2142+
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.8.tgz#715acefdd1223b9c9b37110a149c6392c2852291"
2143+
integrity sha512-PM54PkseWbiiD/mMsbvW351/u+dafwTJ0ye2qB60G1aGQP9j3xK2gmMDc+R34L3nDtx4qMCitXT75mkbkGJDLw==
2144+
21102145
commander@^2.11.0, commander@^2.19.0:
21112146
version "2.19.0"
21122147
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
@@ -2550,9 +2585,9 @@ end-of-stream@^1.1.0:
25502585
once "^1.4.0"
25512586

25522587
envinfo@^7.1.0:
2553-
version "7.1.0"
2554-
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.1.0.tgz#c64f80bbf5faaafc962eef76c0d871c6c672eec0"
2555-
integrity sha512-38LJhrmyQafVInoYlaEDxomIfjtK+HUtp1JsInWdKtpxk0MlTU60fqYHg0LrKgxxJuq6H89ddw4IkxfQejZ77g==
2588+
version "7.3.1"
2589+
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.3.1.tgz#892e42f7bf858b3446d9414ad240dbaf8da52f09"
2590+
integrity sha512-GvXiDTqLYrORVSCuJCsWHPXF5BFvoWMQA9xX4YVjPT1jyS3aZEHUBwjzxU/6LTPF9ReHgVEbX7IEN5UvSXHw/A==
25562591

25572592
error-ex@^1.2.0, error-ex@^1.3.1:
25582593
version "1.3.2"
@@ -3819,6 +3854,11 @@ is-windows@^1.0.2:
38193854
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
38203855
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
38213856

3857+
is-wsl@^1.1.0:
3858+
version "1.1.0"
3859+
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
3860+
integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=
3861+
38223862
[email protected], isarray@~1.0.0:
38233863
version "1.0.0"
38243864
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -5548,12 +5588,12 @@ onetime@^2.0.0:
55485588
dependencies:
55495589
mimic-fn "^1.0.0"
55505590

5551-
opn@^3.0.2:
5552-
version "3.0.3"
5553-
resolved "https://registry.yarnpkg.com/opn/-/opn-3.0.3.tgz#b6d99e7399f78d65c3baaffef1fb288e9b85243a"
5554-
integrity sha1-ttmec5n3jWXDuq/+8fsojpuFJDo=
5591+
open@^6.2.0:
5592+
version "6.3.0"
5593+
resolved "https://registry.yarnpkg.com/open/-/open-6.3.0.tgz#60d0b845ee38fae0631f5d739a21bd40e3d2a527"
5594+
integrity sha512-6AHdrJxPvAXIowO/aIaeHZ8CeMdDf7qCyRNq8NwJpinmCdXhz+NZR7ie1Too94lpciCDsG+qHGO9Mt0svA4OqA==
55555595
dependencies:
5556-
object-assign "^4.0.1"
5596+
is-wsl "^1.1.0"
55575597

55585598
optimist@^0.6.1:
55595599
version "0.6.1"

0 commit comments

Comments
 (0)