Reputation: 149
I am new to react-native and i was trying to integrate dialogflow with react-native.
My code is:
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;
But it shows me this error
Can anyone explain me what problem is this exactly and what correction it needs? Thanks in advance.
Upvotes: 1
Views: 7003
Reputation: 71
Change this:
class App extends Component() {}
for this:
class App extends Component {}
Upvotes: 4
Reputation: 103
That's because it cannot find Dialogflow_V2 reference from props.
Delete this line inside of render function
const { dialogflow } = this.props.Dialogflow_V2;
use Dialogflow_V2 directly that you already have imported.
Dialogflow_V2.requestQuery("hello", result=>console.log(result), error=>console.log(error));
Upvotes: 2
Reputation: 758
You doesn't receive any Dialogflow_V2 props in app component and hence it shows an error. Just replace the following line and i think this will work
const { dialogflow } = this.Dialogflow_V2;
Upvotes: 0