【问题标题】:webview.goBack() throws error: UIManager.dispatchViewManagerCommand got 2 arguments, expected 3 - React Nativewebview.goBack() 抛出错误:UIManager.dispatchViewManagerCommand 有 2 个参数,预期为 3 - React Native
【发布时间】:2019-09-20 11:54:30
【问题描述】:

我正在尝试为 react-native-webview 制作自定义导航控件。 该应用程序抛出此错误(在 andorid 和 ios 中):

这是我在 React Native 中的第一个应用程序,但我在使用 React 进行 Web 开发方面经验丰富。我真的不知道如何调试这个错误。我不确定这个错误是因为 react-native-webview 的错误还是我自己的代码中的错误。

代码

export default class BrowserScreen extends React.Component {

constructor(props) {
  super(props);
  this.state = { canGoBack: false };
}

backHandler = () => {
  if(this.webview){
    this.webview.goBack(); //this throws and error
  }
}

forwardHandler = () => {
  this.webview.goForward();
}

_refWebView = (webview) => {
  if (!webview) {
    return;
  }
  this.webview = webview;
}

render() {
  return (
    <SafeAreaView style={styles.container} >
      <View style={styles.controls}>
        <TouchableOpacity
          onPress={this.backHandler}
        >
          <Text style={styles.icon}>⬅️</Text>
        </TouchableOpacity>
      </View>
    <WebView
      source={{ uri: 'https://google.com' }}
      ref={this._refWebView}
    />
  </SafeAreaView>
  )
 }
}

【问题讨论】:

    标签: react-native react-native-android react-native-ios react-native-webview


    【解决方案1】:

    这是作为react-native-webview7.0.7 版本的一部分意外发布的错误。该错误的修复目前(截至发布此答案)正在审查here,但在它发布以避免此错误之前,您必须使用低于7.0.7react-native-webview版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 2020-12-12
      • 1970-01-01
      • 1970-01-01
      • 2022-11-14
      • 2016-03-29
      • 1970-01-01
      相关资源
      最近更新 更多