React implementation of the Nibi Autocomplete
Make sure you have Node.js 8+ and npm installed.
npm install nibi.ai.nlq@latest --save
npm update nibi.ai.nlq@latest --save
import React, { Component } from 'react'
import NLQSearch from 'nibi.ai.nlq'
import 'nibi.ai.nlq/build/styles.css';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
nibiOptions : {
placement : 'TOP'
},
nibiConfig : {
datasource: 'DATASOURCE', //Required
apiKey: 'API_KEY' //Required
}
}
}
onSearch = (message) => {
console.log('onSearch message', message);
}
beforeAskQuestion = (npl) => {
console.log('beforeAskQuestion npl', npl);
}
render() {
return (
<div>
<NLQSearch config={this.state.nibiConfig} options={this.state.nibiOptions} onSearch={this.onSearch} onBeforeSearch={this.beforeAskQuestion} />
</div>
)
}
}