Skip to content

Replace global mutable map store with React-compatible pattern #86

@tmshv

Description

@tmshv

Problem

src/map.ts uses a module-level mutable Map to store MapLibre map instances:

const store = new Map<string, maplibregl.Map>()

This breaks React's unidirectional data flow, makes testing difficult (no way to mock/reset between tests), and creates an implicit dependency that's hard to trace.

What needs to change

Consider replacing with:

  • A React Context that provides the map instance(s), or
  • Storing the map ref in Redux (as a non-serializable value), or
  • Using react-map-gl's built-in useMap() hook (from MapProvider) consistently throughout the codebase

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions