1.問題描述;
從含有webview的頁面后退時出現了app崩潰,並且並無報錯。
2.版本:
1
2
3
4
|
"react"
:
"16.11.0"
,
"react-native"
:
"0.62.2"
,
"react-native-screens"
:
"^2.10.1"
,
"react-native-webview"
:
"^10.3.2"
,
|
3.造成這種原因的大多說法是 "react-native-screens"和"react-native-webview"沖突。以下是各個關於這個說法的網站鏈接:
react-navigation:https://github.com/react-navigation/react-navigation/issues/8099
https://github.com/react-navigation/react-navigation/issues/6960
文中提到的解決方案有:
⑴在WebView上進行設置androidHardwareAccelerationDisabled (原文地址:https://github.com/software-mansion/react-native-screens/issues/214)
<WebView //style={{ opacity: 0.99}} androidHardwareAccelerationDisabled source={{ html: "<h1 style='font-size: 50px'>Webview: Hello world!</h1>" }} />
問題產生原因:
在 Screen.java中
public void setTransitioning(boolean transitioning) { if (mTransitioning == transitioning) { return; } mTransitioning = transitioning; super.setLayerType(transitioning ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE, null); }
4.最后解決的方式是:
我原在app.js中引入了
import { enableScreens } from 'react-native-screens'; enableScreens();
現在把它刪了,然后頁面返回不會再有崩潰