Comments (4)
@gabe2code I'm not a Typescript user myself, but I'll check this as soon as I get a change.
from react-google-places-autocomplete.
@gabe2code Noticed it's a bug on the typescript definition for the props. Working on a fix now
from react-google-places-autocomplete.
@gabe2code Thanks for catching and reporting this!
In the new release (2.0.4) you can use it like this:
import React from 'react';
import GooglePlacesAutocomplete, { geocodeByPlaceId } from 'react-google-places-autocomplete';
import 'react-google-places-autocomplete/dist/index.min.css';
class App extends React.Component<any, {}> {
onSelect = (selection: any):void => {
geocodeByPlaceId(selection.place_id)
.then(results => results[0])
.then(latLng => console.log('Success', latLng))
.catch(error => console.error('Error', error));
};
renderInput = (props: any):JSX.Element => <input {...props} />
renderSuggestions = (active: number, suggestions: Array<any>, onSelect: (suggestion: any, event: any) => void):JSX.Element => (
<div>
{
suggestions.map(sugg => (
<div
key={sugg.id}
className="suggestion"
onClick={(event) => onSelect(sugg, event)}
>
{sugg.description}
</div>
))
}
</div>
)
render(): React.ReactElement {
return (
<div className="App">
<GooglePlacesAutocomplete
apiKey="*******"
onSelect={this.onSelect}
renderInput={this.renderInput}
renderSuggestions={this.renderSuggestions}
/>
</div>
);
}
}
export default App;
from react-google-places-autocomplete.
Hi @Tintef , looks very good, thanks for the help 👍
from react-google-places-autocomplete.
Related Issues (20)
- Autocomplete options are behind other sections HOT 3
- Styling HOT 1
- Error: [react-google-places-autocomplete]: Google script not loaded HOT 4
- Error accessing 'place_id' property when rendering component dynamically HOT 1
- Error whle compiling HOT 1
- Placeholder not clearing on focus HOT 1
- Query & Show Suggestions on Focus
- handling of error when request quotas exceeded for 'places api'
- how to style the input HOT 2
- Autocomplete Request: Bounds deprecated HOT 1
- isMulti Prop Does Not Accept true in react-google-places-autocomplete v4.0.1
- Setting pointerEvents on listView Not Honored
- Google Maps JavaScript API has been loaded directly without loading=async HOT 11
- Minimizing Data Requests to Stay Within Google Places API Free Tier
- Getting warning regarding "Google Maps JavaScript API has been loaded directly without loading=async. This can result in suboptimal performance. For best-practice loading patterns please see https://goo.gle/js-api-loading HOT 2
- PlaceHolder not showing HOT 2
- Autofill functionality in browsers fails to operate when the placeholder is anything other than an empty string.
- Support for defaultProps error. HOT 2
- Uncaught SyntaxError: Unexpected token '<' HOT 1
- Failed to load resource: the server responded with a status of 404 () in reactjs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-google-places-autocomplete.