diff --git a/docs/api-reference/geolocate-control.md b/docs/api-reference/geolocate-control.md index 578b59d5..06debba0 100644 --- a/docs/api-reference/geolocate-control.md +++ b/docs/api-reference/geolocate-control.md @@ -29,11 +29,12 @@ import * as React from 'react'; import Map, {GeolocateControl} from 'react-map-gl'; function App() { - const geolocateControlRef = React.useRef(); - - React.useEffect(() => { - geolocateControlRef.current.trigger(); - }, []) + const geolocateControlRef = React.useCallback((ref) => { + if (ref) { + // Activate as soon as the control is loaded + ref.trigger(); + } + }, []); return ; } diff --git a/docs/api-reference/map.md b/docs/api-reference/map.md index 97b2b37b..a4dfbb52 100644 --- a/docs/api-reference/map.md +++ b/docs/api-reference/map.md @@ -32,13 +32,13 @@ import Map from 'react-map-gl'; function App() { const mapRef = React.useRef(); - React.useEffect(() => { - mapRef.current.on('styleimagemissing', () => { + const onMapLoad = React.useCallback(() => { + mapRef.current.on('move', () => { // do something }); - }, []) + }, []); - return ; + return ; } ``` diff --git a/docs/get-started/get-started.md b/docs/get-started/get-started.md index 62300162..bf9a5119 100644 --- a/docs/get-started/get-started.md +++ b/docs/get-started/get-started.md @@ -59,6 +59,9 @@ Install your choice of fork along with react-map-gl, for example: ```bash npm install --save react-map-gl maplibre-gl + +# Add an empty placeholder for mapbox-gl to satisfy the peer dependency +npm install --save mapbox-gl@npm:empty-npm-package@1.0.0 ``` Then override the `mapLib` prop of `Map`: diff --git a/examples/get-started/maplibre/package.json b/examples/get-started/maplibre/package.json index fa4f29ac..f1b4d28f 100644 --- a/examples/get-started/maplibre/package.json +++ b/examples/get-started/maplibre/package.json @@ -4,7 +4,7 @@ "build": "webpack --mode=production -o ./dist" }, "dependencies": { - "mapbox-gl": "^1.0.0", + "mapbox-gl": "npm:empty-npm-package@1.0.0", "maplibre-gl": "^2.0.0", "react": "^17.0.0", "react-dom": "^17.0.0", diff --git a/yarn.lock b/yarn.lock index 0e8677a1..d618cecb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3389,9 +3389,9 @@ camelcase@^5.0.0, camelcase@^5.3.1: integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== caniuse-lite@^1.0.30001286: - version "1.0.30001309" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001309.tgz" - integrity sha512-Pl8vfigmBXXq+/yUz1jUwULeq9xhMJznzdc/xwl4WclDAuebcTHVefpz8lE/bMI+UN7TOkSSe7B7RnZd6+dzjA== + version "1.0.30001312" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001312.tgz" + integrity sha512-Wiz1Psk2MEK0pX3rUzWaunLTZzqS2JYZFzNKqAiJGiuxIjRPLgV6+VDPOg6lQOUxmDwhTlh198JsTTi8Hzw6aQ== caseless@~0.12.0: version "0.12.0"