Closed kkatusic closed 1 day ago
The latest updates on your projects. Learn more about Vercel for Git βοΈ
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
giveth-dapps-v2 | β Ready (Inspect) | Visit Preview | π¬ Add feedback | Jun 28, 2024 5:09pm |
The update replaces the deprecated react-google-maps
and react-places-autocomplete
libraries with @react-google-maps/api
across multiple components. This includes refactoring components to use React hooks and simplifying the handling of Google Maps and Places API integration.
File | Change Summary |
---|---|
package.json |
Added @react-google-maps/api , removed react-google-maps and react-places-autocomplete . |
.../views/create/locationInput/GoogleMap.tsx | Updated to use @react-google-maps/api and refactored GoogleMapComponent . |
.../views/create/locationInput/Location.index.tsx | Removed googleMapURL and loadingElement usage. |
.../views/create/locationInput/LocationInput.tsx | Converted class component to functional component using hooks, updated imports and functionality for Google Maps API. |
.../views/create/locationInput/SearchPlaces.tsx | Refactored to utilize StandaloneSearchBox from @react-google-maps/api , updated state management. |
Objective | Addressed | Explanation |
---|---|---|
Replace react-google-maps with @react-google-maps/api (#4317) |
β |
In codeβs vast field, we took a leap,
With APIs fresh, old scripts asleep. π
Maps now load with a seamless grace,
Hooks in place, functions ace.
A rabbitβs cheer, for work well done,
Our journey forward has just begun! πβ¨
src/components/views/create/locationInput/LocationInput.tsx
[error] 31-34: This else clause can be omitted because previous branches break early. Unsafe fix: Omit the else clause. (lint/style/noUselessElse)
src/components/views/create/locationInput/GoogleMap.tsx (3)
`2-2`: **Updated import statement to use new Google Maps API.** The import change from `react-google-maps` to `@react-google-maps/api` aligns with the PR objectives of updating the library for better support and features. --- `6-12`: **Proper use of GoogleMap component with updated props.** The `GoogleMap` component is correctly implemented with `mapContainerStyle`, `center`, and `zoom` properties. The `options` object correctly disables unwanted UI elements and makes the map non-draggable, which might be intended for static display purposes. --- `16-21`: **Check consistency of mapContainerStyle across different resolutions.** Given the fixed height and width, ensure that the map displays correctly across various device resolutions and orientations.src/components/views/create/locationInput/LocationInput.tsx (1)
`1-10`: **Refactored to use React hooks and updated imports.** The transition from class-based to functional components using hooks (`useState`, `useEffect`, `useCallback`) is a modern React practice that enhances readability and maintainability.src/components/views/create/locationInput/SearchPlaces.tsx (3)
`1-11`: **Updated component to use `StandaloneSearchBox`.** The use of `StandaloneSearchBox` from `@react-google-maps/api` for handling place searches directly aligns with the PR's goal to leverage more modern and maintained libraries. --- `14-56`: **Review the handling of search box state and place selection.** The component effectively manages the state of the search box, places, and selected place. It also correctly handles the event when a place is selected, ensuring that the address and coordinates are passed to the parent component. --- `86-115`: **Custom styles for Google Places autocomplete are well-defined.** The custom styles for the autocomplete dropdown are specific and ensure that the UI element is visually consistent with the rest of the application. The use of `z-index` and `box-shadow` enhances the dropdown's visibility and aesthetic.
Resolve #4317
@MohammadPCh this is PR for replacing google map libraries. Please note that I needed to remove two packages: react-google-maps and react-places-autocomplete.
I lost time to handle all states, so you will need to check state management in three files am I placed it goods. Also test does map is showing to you, I needed to create my api key to enable Place API.
This new package has searchbox already implemented I used it and removed old one.
thx
Summary by CodeRabbit
Refactor
@react-google-maps/api
instead of deprecatedreact-google-maps
.LocationInput
component to a functional component with hooks for improved performance and readability.SearchPlaces
component to useStandaloneSearchBox
for location search.New Features
Dependency Updates
@react-google-maps/api
.react-google-maps
andreact-places-autocomplete
.