Shahid Anjum
Shahid Anjum

Reputation: 148

Loading Static HTML content and adding baseUrl to it, using react-native-webview. returns unexpected url on click

I am using react-native-webview. I am adding static HTML content into it, with baseUrl for relative path. { console.log(navState); }} /> on Clicking a link there in Webview, getting the below log: { canGoForward: false, canGoBack: false, title: "", loading: true, url: "data:text/html;charset=utf-8;base64,", …}

How to get the exact url? I'm trying this on Android Emulator

Upvotes: 0

Views: 617

Answers (1)

Vignesh V Pai
Vignesh V Pai

Reputation: 829

Assuming that you're referring to navState object of the onNavigationStateChange function when you did the following:

onNavigationStateChange={navState => { //some logic }}

The navState object includes these properties:

canGoBack
canGoForward
loading
navigationType
target
title
url

In fact, you console logged the navState object.

To get the URL, use navState.url. Hence console.log(navState.url) would log the URL.

Note: This method will not be invoked on hash URL changes. See this.

Upvotes: 2

Related Questions