Я только что обновил свое приложение React до React 16.0 с 15.x и теперь получаю следующую ошибку.Сам код не изменился, за исключением того факта, что теперь это приложение React 16.0.
«Google» не определен no-undef
Я использую автозаполнениефункция в методе util, которую я создал следующим образом:
const map = new google.maps.Map(document.createElement('div'));
const googlePlacesAutocomplete = new google.maps.places.AutocompleteService();
const googlePlacesService = new google.maps.places.PlacesService(map);
export const googlePlacesAutoComplete = (keyword, callback) => {
googlePlacesAutocomplete.getQueryPredictions({input: keyword}, (predictions, status) => {
if(status !== google.maps.places.PlacesServiceStatus.OK) return callback(null);
return callback(predictions);
});
}
Я просто указываю на библиотеки Google Places со статической HTML-страницы для точки входа моего приложения React.
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&key=my-api-key"></script>
Любая идея, чтонеправильно?Любые предложения, чтобы это исправить?