Skip to content

Commit

Permalink
feat(useWebMap)!: accepts a div instead of a ref of a div
Browse files Browse the repository at this point in the history
migration: update your call sites to pass the ref.current instead of the ref directly
  • Loading branch information
steveoh committed Jan 22, 2025
1 parent ff77bc6 commit b2c10c7
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/utilities/src/hooks/useWebMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ import MapView from '@arcgis/core/views/MapView.js';
import WebMap from '@arcgis/core/WebMap.js';
import { useEffect, useRef } from 'react';

export default function useWebMap(
div: React.RefObject<HTMLDivElement>,
id: string,
) {
export default function useWebMap(div: HTMLDivElement, id: string) {
const webMap = useRef<WebMap | null>(null);
const mapView = useRef<MapView | null>(null);

useEffect(() => {
if (div.current) {
if (div) {
webMap.current = new WebMap({
portalItem: {
id,
},
});

mapView.current = new MapView({
container: div.current,
container: div,
map: webMap.current,
});
}
Expand Down

0 comments on commit b2c10c7

Please sign in to comment.