[Bug] Mapbox geocoder example crashes: "i is not a function"

Đang mở
#2,628 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@yuiseki đang làm issue này rồi.

Từ ngày 11/11/2026.

  • #2629 của @yuiseki — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
node.js, react, typescript, webpack
Lĩnh vực
frontend, web-dev

Hướng nghiên cứu

Start with the website's webpack configuration and how it resolves the nested nanoid dependency used by @mapbox/mapbox-gl-geocoder. Reproduce by opening the Mapbox geocoder example at /examples/mapbox/geocoder and check whether the control renders without the reported TypeError. Done means the example loads with the geocoder control; pull request #2629 is already open against this issue.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description

The Mapbox geocoder example on the website crashes on load with TypeError: i is not a function.

The error is thrown in generateSessionID() of @mapbox/[email protected], which calls require('nanoid')() and expects nanoid@2. The website's webpack config sets resolve.modules to absolute paths (from @vis.gl/docusaurus-website), so the nested nanoid@2 is skipped and the hoisted nanoid@3 is bundled. nanoid@3 has no default export.

image
Expected Behavior

The example renders a map with the geocoder control.

Steps to Reproduce

Open https://visgl.github.io/react-map-gl/examples/mapbox/geocoder

Environment
Logs
TypeError: i is not a function
    at generateSessionID
    at onAdd
    at addControl
Ngôn ngữ chính
TypeScript
Star
8.5k
Fork
1.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của visgl/react-map-gl

Tất cả issue của visgl/react-map-gl

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.