Dan Jírovec
Dan Jírovec

Reputation: 3

React Native Web View Redirect

this my Web View in React Native:

<WebView
injectedJavaScriptBeforeContentLoaded={injectedJs}
startInLoadingState={true}
ref={webViewRef}
onTouchStart={() => setScrollEnabled(false)}
onTouchEnd={() => setScrollEnabled(true)}
className="w-96 h-96 my-2.5"
scalesPageToFit={true}
originWhitelist={['https://google.com']}
onMessage={handleOnMessage}
source={{uri: 'https://google.com'}}
/>

When I open the screen where this Web View is, it automatically redirects my to my default mobile browser and opens google.com. Even when I make scalesPageToFit to false.

But I want to stay in the app and only render the Web View with specific size in my screen.

When I use local site (like localhost:5173), it works fine but when I define source={{ uri: ...}} to be an actual website, it always redirects me.

Why is this happening?

I have React Native Web View version 13.8.6, React Native version 0.74.5 and Expo version 51.0.38.

Thank you for your help.

Upvotes: 0

Views: 63

Answers (0)

Related Questions