[Bug] "Cannot update a component while rendering a different component" error in `dataloading` event handler
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- data-visualization, frontend
Hướng nghiên cứu
Bắt đầu với source.js và bản tái hiện CodeSandbox được cung cấp, sau đó lần theo handler dataloading qua updateSource và component Source bằng stack trace. Xác nhận cảnh báo với các phiên bản React, thư viện bản đồ, trình duyệt và hệ điều hành được liệt kê. Hoàn tất khi các handler dataloading có thể cập nhật state của một component khác mà không gây ra cảnh báo trong thời gian render.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
When there is an event handler hooked to mapRef's dataloading event
and this handler calls setState (say, for enabling spinning wheel feedback),
the following "Warning"-level exception is dumped:
Warning: Cannot update a component (
MyMap) while rendering a different component (Source). To locate the bad setState() call insideSource, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
This seems to be caused by component calling updateSource during rendering.
Maybe this should be an in-effect code instead.
Expected Behavior
Event handlers should allow updating state of other components.
Steps to Reproduce
Minimal example provided here. See "Console" tab for the actual error.
https://codesandbox.io/s/optimistic-monad-dyt59s?file=/src/index.js
Environment
- Framework version: 7.0.20
- Map library: 2.4.0
- Browser: Firefox
- OS: Linux
Logs
Relevant stack trace fragment below.
setTrue useBoolean.js:4 (*** state setter ***)
dataloading (*** my event handler ***)
fire maplibre-gl.js:535
_fireEvent mapbox.js:488
fire maplibre-gl.js:539
fire maplibre-gl.js:539
fire maplibre-gl.js:539
_updateWorkerData maplibre-gl.js:15287
setData maplibre-gl.js:15262
updateSource source.js:39
Source source.js:102
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của visgl/react-map-gl
-
DEFAULT_SETTINGS.maxBounds in @vis.gl/react-maplibre has 360° longitude span, triggers maplibre-gl-js#6148 crash via _updateSettings fallbackCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
visgl/react-map-gl#2591 · 2 bình luận ·
-
[Bug] Mapbox geocoder example crashes: "i is not a function"Có thể đã có người làm @yuiseki đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
visgl/react-map-gl#2628 ·
-
[Bug] Scroll zoom stops short of maxZoom in controlled mode with MapLibreCó thể đã có người làm @sviat-barbutsa đã nhận 33 ngày trước. Đang mởbug
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 74/100
visgl/react-map-gl#2626 ·
-
[Bug] reuseMaps: Mapbox.reuse() infinite-loops (tab freeze) when the recycled map's container is the mount containerCó thể đã có người làm @mikeyfarina đã nhận 82 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
visgl/react-map-gl#2613 ·
-
feature
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
visgl/react-map-gl#2603 · 1 reaction ·
Tất cả issue của visgl/react-map-gl
Issue tương tự
-
accessibility area:ci ci-test level:low priority:high type:test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 71/100
skytuhua-org/Gen-V1#3132 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
drmrd/vernacular#1238 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
enhancement migration-prioritized
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Hudson-Pufferfish/local-party-console#136 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày