In a web view,I want to swipe the page from left to right in order to go back,just like what safari did. what should I do?
TL/DR: Currently, you'll need a third party package for that. Use the react-native-wkwebview-reborn package and set the allowsBackForwardNavigationGestures
prop to true. Example:
WebView.ios.js
:
import React from 'react';
import WKWebView from 'react-native-wkwebview-reborn';
export default (props) => <WKWebView allowsBackForwardNavigationGestures {...props} />
WebView.js
import { WebView } from 'react-native';
export default WebView;
It's a drop-in replacement, so you won't need to change much code.
Why:
The WebView
component from React Native uses UIWebView under the hood, which is not recommended by Apple anymore:
It has worse performance and does not support a lot of features, like 3D Touch and swipe back gesture.
Join this discussion so react native updates their core component.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With