React-Native:undefined不是对象(评估'this.props = props')

拉梅什·拉加万(Ramesh Raghavan)

我是React-native的新手,我正尝试将dialogflow与react-native集成。

我的代码是:

import React, {Component} from 'react';
import { StyleSheet, View, Button } from 'react-native';
import { Dialogflow_V2 } from "react-native-dialogflow";

class App extends Component() {
  constructor(props) {
    super(props);

    Dialogflow_V2.setConfiguration(
        "sample.iam.gserviceaccount.com",
        '-----BEGIN PRIVATE KEY-----\sample\n-----END PRIVATE KEY-----\n"',
        Dialogflow_V2.LANG_ENGLISH,
        'sample-44ce3'
    );
  }
  render() {
    const { dialogflow } = this.props.Dialogflow_V2;
    return (
      <View style={styles.container}>
        <Button onPress={() => {
            dialogflow.requestQuery("hello", result=>console.log(result), error=>console.log(error));
          }}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

export default App;

但这告诉我这个错误

在此处输入图片说明

谁能向我解释这到底是什么问题,需要什么纠正?提前致谢。

崔成镐

那是因为它无法从道具中找到Dialogflow_V2参考。

在渲染函数中删除此行

const { dialogflow } = this.props.Dialogflow_V2;

直接使用您已经导入的Dialogflow_V2

Dialogflow_V2.requestQuery("hello", result=>console.log(result), error=>console.log(error));

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

React Native TypeError:undefined 不是对象(评估“props.getItem”)

React Native:undefined 不是对象(评估“props.navigation.navigate”)

React Native:undefined 不是一个对象(评估'_this2.props.navigation.navigate')

React Native:TypeError:undefined不是一个对象(评估'_this.props.data.map')

react-native: undefined 不是带有反应导航的对象(评估“_this2.props.navigation”)

undefined不是对象(评估'_this2.props.navigation.navigate')-React Native

React Native:TypeError:undefined不是一个对象(评估'this.props.navigation.navigate')

React-native:undefined不是对象(评估'_this3.props.navigation.navigate')

React Native undefined不是一个对象(评估“ props.navigation.toggleDrawer”)

Undefined 不是一个对象(评估'this.props.navigation.navigate')React native

React Redux - undefined 不是评估 this.props.navigation.navigate 的对象

react-native:undefined中的抽屉导航错误不是一个对象(评估'_this.props.navigation.openDrawer()')

undefined不是对象(评估'_props [registrationName]')

undefined 不是对象(评估“this.props”)

React - props 不是函数

React undefined props issue

React Native:Undefined不是一个函数(评估this.props ...)

未定义的React Native NavigatorIOS不是对象(评估'this.props.navigator.push')

React Native-未定义不是对象(评估this.props.isLoggedIn.then)

React Native 中的堆栈导航器。错误“未定义不是对象(评估 this.props.navigation)”

React props 返回为 undefined

React Native props.navigation.navigate不是对象

React Native什么是Props类型?

反应native:undefined不是对象(评估'_this2.props.navigation.navigate')

react-native-navigation给出错误“未定义不是对象(正在评估'_this.props.navigation.navigate')”

组件异常:undefined不是对象(评估“ props.textInputId”)

undefined不是onPress的对象(评估this.props.navigation.navigate)

TypeError : undefined 不是对象(评估“this3.props”)

React 子组件 props : _this2.props.delete 不是函数