Skip to content

Commit d4799a4

Browse files
committed
refactor(README): update example usage code for elevation hooK
1 parent caf6445 commit d4799a4

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -485,19 +485,22 @@ React hook to use the [Elevation Service](https://developers.google.com/maps/doc
485485

486486
#### Usage
487487

488-
```jsx
489-
import React from 'react';
488+
```tsx
489+
import React, {useEffect} from 'react';
490490
import {useElevationService} from '@ubilabs/google-maps-react-hooks';
491491

492492
const MyComponent = () => {
493493
const elevator = useElevationService();
494-
495-
elevator?.getElevationForLocations(
496-
{locations: [location]},
497-
(results: google.maps.ElevationResult[]) => {
498-
// Do something with results
499-
}
500-
);
494+
const location = /** google.maps.LatLng */;
495+
496+
useEffect(() => {
497+
elevator?.getElevationForLocations(
498+
{locations: [location]},
499+
(results: google.maps.ElevationResult[]) => {
500+
// Do something with results
501+
}
502+
);
503+
}, [location]);
501504

502505
return (...);
503506
};

0 commit comments

Comments
 (0)