I'm trying to use the jquery auto-complete plugin in a React component.
I've installed the plugin using npm install jquery-autocomplete --save
Next I try to use the plugin like this in my React component:
import React, { Component } from "react";
import jQuery from "jquery";
// import $ frmom 'jQuery';
import autocomplete from "jquery-autocomplete";
class AutoComplete extends Component {
componentDidMount() {
this.refs.autoCompleteInput.autocomplete({
source: ["aaa", "aab", "aac", "abb", "bbb"]
});
}
state = {};
render() {
return <input ref="autoCompleteInput" />;
}
}
export default AutoComplete;
When using this code, I get this error messages ReferenceError: jQuery is not defined
.
What do I need to do so I can use the jQuery plugin?
Edit: I've also tried these lines without success:
//import { jQuery } from "jquery";
import "jquery";