Skip to content

Cannot assign to import "accessToken" error on Remix  #1013

Open
@maciej-adamus

Description

@maciej-adamus

I am trying to use the library in Remix environment. When I import and use the map component, I am getting this error:

X [ERROR] Cannot assign to import "accessToken"

     node_modules/react-mapbox-gl/lib-esm/map.js:59:25:
       59 │                 MapboxGl.accessToken = accessToken;
          ╵                          ~~~~~~~~~~~
   
      Imports are immutable in JavaScript. To modify the value of this import, you must export a setter function in the imported file (e.g. "setAccessToken") and then import and call 
that function here instead.
   
   
    Build failed with 1 error:
    node_modules/react-mapbox-gl/lib-esm/map.js:59:25: ERROR: Cannot assign to import "accessToken"

Here it says that since v1.2 the accessToken can be passed as a parameter to Map constructor. Why not do it that way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions