Skip to content

Commit 05774c8

Browse files
committed
fix: stop webView from crashing
- stopLoading() should prevent webView from loading the custom uri
1 parent 22b3a19 commit 05774c8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/react-native/Login.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import React, { useState, useRef } from 'react'
22
import {
33
Dimensions,
44
ImageBackground,
@@ -21,6 +21,7 @@ const store = 'dimensionsoftware', // YOUR-STORE.myshopify.com
2121
export default function Login() {
2222
const [email, setEmail] = useState<string>(''),
2323
[socialUri, setSocialUri] = useState<string>(''),
24+
webView = useRef(null),
2425
doLogin = async () => {
2526
// initiate passwordless email login
2627
const r = await passwordless({ email })
@@ -87,6 +88,7 @@ export default function Login() {
8788
</View>
8889
<Modal visible={!!socialUri} animationType="slide">
8990
<WebView
91+
ref={webView}
9092
source={{
9193
uri: socialUri
9294
}}
@@ -95,8 +97,10 @@ export default function Login() {
9597
// success, so--
9698
setSocialUri('') // reset ui
9799
Linking.openURL(e.url) // send CustomerAccessToken to app
100+
webView.current.stopLoading() // halt webView
101+
return false
98102
}
99-
return !!!e.url.match(/^passwordless-/)
103+
return true
100104
}}
101105
javaScriptEnabled={true}
102106
domStorageEnabled={true}

0 commit comments

Comments
 (0)