Skip to content

Commit

Permalink
update mapbox map to latest react
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuyedavid committed Feb 16, 2024
1 parent 76fcf6a commit c4a2e8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/components/MapboxMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useRef, useEffect } from 'react';
import mapboxgl from 'mapbox-gl';
import { Result, useSearchState } from '@yext/search-headless-react';
import { useDebouncedFunction } from '../hooks/useDebouncedFunction';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';

Check failure on line 5 in src/components/MapboxMap.tsx

View workflow job for this annotation

GitHub Actions / call_run_tests-react-16 / tests (16.x)

Cannot find module 'react-dom/client' or its corresponding type declarations.

Check failure on line 5 in src/components/MapboxMap.tsx

View workflow job for this annotation

GitHub Actions / call_run_tests-react-17 / tests (16.x)

Cannot find module 'react-dom/client' or its corresponding type declarations.

Check failure on line 5 in src/components/MapboxMap.tsx

View workflow job for this annotation

GitHub Actions / call_run_tests-react-16 / tests (18.x)

Cannot find module 'react-dom/client' or its corresponding type declarations.

Check failure on line 5 in src/components/MapboxMap.tsx

View workflow job for this annotation

GitHub Actions / call_run_tests-react-17 / tests (18.x)

Cannot find module 'react-dom/client' or its corresponding type declarations.

Check failure on line 5 in src/components/MapboxMap.tsx

View workflow job for this annotation

GitHub Actions / call_run_tests-react-16 / tests (16.x)

Cannot find module 'react-dom/client' or its corresponding type declarations.

Check failure on line 5 in src/components/MapboxMap.tsx

View workflow job for this annotation

GitHub Actions / call_run_tests-react-16 / tests (18.x)

Cannot find module 'react-dom/client' or its corresponding type declarations.

Check failure on line 5 in src/components/MapboxMap.tsx

View workflow job for this annotation

GitHub Actions / call_run_tests-react-17 / tests (16.x)

Cannot find module 'react-dom/client' or its corresponding type declarations.

Check failure on line 5 in src/components/MapboxMap.tsx

View workflow job for this annotation

GitHub Actions / call_run_tests-react-17 / tests (18.x)

Cannot find module 'react-dom/client' or its corresponding type declarations.

/**
* A functional component that can be used to render a custom marker on the map.
Expand Down Expand Up @@ -136,11 +136,14 @@ export function MapboxMap<T>({
const el = document.createElement('div');
const markerOptions: mapboxgl.MarkerOptions = {};
if (PinComponent) {
ReactDOM.render(<PinComponent
index={i}
mapbox={mapbox}
result={result}
/>, el);
const root = createRoot(el!);
root.render(
<PinComponent
index={i}
mapbox={mapbox}
result={result}
/>
);
markerOptions.element = el;
}
const marker = new mapboxgl.Marker(markerOptions)
Expand Down Expand Up @@ -183,4 +186,4 @@ function getDefaultCoordinate<T>(result: Result<T>): Coordinate | undefined {
return undefined;
}
return yextDisplayCoordinate;
}
}
2 changes: 1 addition & 1 deletion test-site/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CloudRegion, Environment } from '@yext/search-headless-react';

export const config = {
apiKey: process.env.REACT_APP_LIVE_API_KEY || 'REPLACE_ME',
apiKey: '2d8c550071a64ea23e263118a2b0680b',
experienceKey: 'slanswers-hier-facets',
locale: 'en',
experienceVersion: 'STAGING',
Expand Down

0 comments on commit c4a2e8d

Please sign in to comment.