Skip to content

Bug: Cannot read properties of undefined (reading 'getMap') after updated to 1.0.0-next #140

@Coldsewoo

Description

@Coldsewoo

Tested versions (local / reproduce)

  • three version: 0.166.0 / 0.165.0
  • @react-three/fiber version: 8.15.12 / 8.16.8
  • react-three-map version: 1.0.0-next.0 / 1.0.0-next.0
  • node version: 18.18.2 / 22.14.0
  • npm (or yarn) version: 9.2.0 / 11.1.0

Problem description:

I got a Cannot read properties of undefined (reading 'getMap') in Canvas.tsx line 22 after updated to 1.0.0

  const map = useMap().current!.getMap(); // eslint-disable-line @typescript-eslint/no-non-null-assertion

upon loading a canvas.

Relevant code:

https://codesandbox.io/p/devbox/react-three-map-gettings-started-forked-l4sjk7

I've updated the dependencies, but nothing significant changed.

Suggested solution:

The error occurs even when a valid access token isn't provided, so perhaps it needs to wait until the map is fully loaded—at least until useMap() becomes available—or a check should be added for when useMap() returns null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions