diff --git a/docs/examples.json b/docs/examples.json index d0392162e..ccaf59dc8 100644 --- a/docs/examples.json +++ b/docs/examples.json @@ -260,6 +260,16 @@ "relPath": "Map/MapAndRNNavigation.js", "name": "MapAndRNNavigation" }, + { + "metadata": { + "title": "Map (un-)mount", + "tags": [], + "docs": "\nShowing and hiding the the map should not lead to increased memory consumption, use this example to check it on the profiler.\n" + }, + "fullPath": "example/src/examples/Map/MapUnMount.tsx", + "relPath": "Map/MapUnMount.tsx", + "name": "MapUnMount" + }, { "metadata": { "title": "Offline Example", diff --git a/example/src/examples/Map/MapUnMount.tsx b/example/src/examples/Map/MapUnMount.tsx new file mode 100644 index 000000000..1d4882181 --- /dev/null +++ b/example/src/examples/Map/MapUnMount.tsx @@ -0,0 +1,51 @@ +import React, { useState, useEffect } from 'react'; +import Mapbox from '@rnmapbox/maps'; +import { Button } from '@rneui/base'; + +import sheet from '../../styles/sheet'; +import { ExampleWithMetadata } from '../common/ExampleMetadata'; // exclude-from-doc + +const MapUnMount = () => { + const [isMounted, setIsMounted] = useState(true); + + useEffect(() => { + Mapbox.locationManager.start(); + + return (): void => { + Mapbox.locationManager.stop(); + }; + }, []); + + return ( + <> +