gpt4 book ai didi

ios - React-Native-Webview:预期 nodeHandle 不为空

转载 作者:行者123 更新时间:2023-11-29 11:29:04 25 4
gpt4 key购买 nike

我正在使用 react-native-webview 来呈现 webview。当我在 webview 中从一个页面导航到另一个页面,然后尝试使用 this.webviewref.goBack() 返回时,我得到了 nodeHandle expected to be non-null.

这是我的代码

 <View style={{ flex: 1 }}>
<Header
headingText={headerText}
onpress={() => {
// this.dispatchCustomEvent(BACK_PRESS);
if (this.canGoBack) {
this.webViewRef.goBack();
} else NavigationActions.pop();
}}
/>
<WebView
source={{ uri: "http://localhost:3001/invite/" }}
bounces={false}
javaScriptEnabled={true}
ref={webViewRef => (this.webViewRef = webViewRef)}
// injectedJavaScript={patchPostMessageJsCode}
onMessage={event => {
const { type, data } = JSON.parse(event.nativeEvent.data);
console.log({ type });
console.log({ data });
this.handleEvent(type, data);
}}
onNavigationStateChange={navState =>
(this.canGoBack = navState.canGoBack)
}
/>
</View>

控制台日志记录 this.webViewRef 显示 weViewRef 中存在 goBack 方法

抛出 nodeHandle expected to be non-null 的代码可以在这里找到 https://github.com/react-native-community/react-native-webview/blob/master/src/WebView.ios.tsx

我无法理解 getWebViewHandle 有什么问题以及为什么 nodeHandle 为 null。

最佳答案

我遇到了同样的问题。原来是我的react-native版本太低了。它至少需要 0.57。升级到0.59.5及其他依赖后,该问题消失。

关于ios - React-Native-Webview:预期 nodeHandle 不为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55535654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com