Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
Memory: 82.27 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.3 - /usr/local/bin/node
npm: 5.6.0 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
IDEs:
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728
react-native: 0.57.4 => 0.57.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
Description
When the useWebKit prop is set on the WebView component the underlying WKWebView instance does not get disposed of after the component is unmounted. These lingering instances can be seen using the Develop menu in Safari. This is only a problem when the useWebKit prop is set.
Reproducible Demo
- Run the following code using
react-native run-ios from the repository or by copy/pasting into App.js in a newly initialized React Native project.
- Launch Safari and verify that you can see JSContext running in the simulator.
- Click the 'Toggle WebView' button to mount and unmount the WebView component.
- Verify that the unmounted WKWebView instances are still active and accessible via Safari.
- Remove the
useWebKit prop and re-run to verify this only happens when that prop is set.
Repository: https://github.com/jacamera/rnWebviewTest
App.js:
import React, {Component} from 'react';
import {View, Button, WebView} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
constructor(props) {
super(props);
this.state = { showWebView: false };
this._toggleWebView = () => {
this.setState(prevState => ({ showWebView: !prevState.showWebView }));
};
}
render() {
return (
<View style={{ flex: 1, padding: 50 }}>
<Button
onPress={this._toggleWebView}
title="Toggle WebView"
/>
{this.state.showWebView ?
<WebView
source={{ uri: 'https://www.google.com' }}
useWebKit
/> :
null}
</View>
);
}
}
Screenshot:

Environment
Description
When the
useWebKitprop is set on theWebViewcomponent the underlying WKWebView instance does not get disposed of after the component is unmounted. These lingering instances can be seen using the Develop menu in Safari. This is only a problem when theuseWebKitprop is set.Reproducible Demo
react-native run-iosfrom the repository or by copy/pasting into App.js in a newly initialized React Native project.useWebKitprop and re-run to verify this only happens when that prop is set.Repository: https://github.com/jacamera/rnWebviewTest
App.js:
Screenshot:
