React-native: WebView didn't get canGoBack correctly

Created on 7 Jul 2017  路  12Comments  路  Source: facebook/react-native

Have you read the Bugs section of the Contributing to React Native Guide?

(Write your answer here.)

Environment

  1. react-native -v:
    react-native-cli: 2.0.1
    react-native: 0.45.1
  2. node -v:
    v8.1.2
  3. npm -v:
    5.0.3
  4. yarn --version (if you use Yarn):
    0.24.6

Then, specify:

  1. Target Platform (e.g. iOS, Android):
    iOS
  2. Development Operating System (e.g. macOS Sierra, Windows 10):
    macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant):
    iOS >8.0 Xcode 8.3.3

Steps to Reproduce

1.add an webView and a button call webView's goBack
2.view some page and go back
3.check whether the canGoBack is right

Expected Behavior

the canGoBack is false when back to the first page
the canGoBack is true when viewing deeper page

Actual Behavior

the canGoBack sometime is false at the page which is not the first loaded page.

Locked

Most helpful comment

Just confirming this is a bug.

To Reproduce:

  1. Instantiate a WebView like so
    <WebView
        source={{ uri: 'https://www.google.com' }}
        onNavigationStateChange={ ({ canGoback }) => console.log(canGoBack) }
    />
  1. Click anything (eg the banner image) to navigate to a new page

What Happens:
The console logs false as the next page begins to load, and then true after the page has loaded

What should happen:
The console logs true as the next page begins to load and true after the page has loaded

All 12 comments

The bug report is missing some necessary details. Please read the contributing guide and open a new issue, thanks!

same problem.
canGoBack sometimes correct but sometimes wrong.

When the second page is loading, I get onNavigationStateChange callback contains wrong canGoBack as false, after loading finished, I get correct canGoBack. Tested on iOS 10.0.3 & Android 7.1.1, RN 0.49.3.

same issue as @0x5e in RN 0.50.3

+1

Still happening, this especially hurts because there's no other way (that I know of) to correctly tell if the current webview can go back.

Just confirming this is a bug.

To Reproduce:

  1. Instantiate a WebView like so
    <WebView
        source={{ uri: 'https://www.google.com' }}
        onNavigationStateChange={ ({ canGoback }) => console.log(canGoBack) }
    />
  1. Click anything (eg the banner image) to navigate to a new page

What Happens:
The console logs false as the next page begins to load, and then true after the page has loaded

What should happen:
The console logs true as the next page begins to load and true after the page has loaded

in android the console logs true as the next page begins to load and true after the page has loaded
in ios is wrong

@hramos Please open this bug again 馃

Please open a new issue.

When the second page is loading, I don't get onNavigationStateChange callback , Tested on iOS 10.3.3 , RN 0.46.2, but the Android don't have this bug

Not fist page,iOS 11.0 no have this problem,canGoback == true,but iOS 11.4 have this problem, canGoback == false.

Was this page helpful?
0 / 5 - 0 ratings