[Bug] "Cannot update a component while rendering a different component" error in `dataloading` event handler
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
調査の方向性
source.js と提供された CodeSandbox の再現から始め、スタックトレースを使って dataloading ハンドラーを updateSource と Source コンポーネントまで追跡します。記載されている React、マップライブラリ、ブラウザー、OS のバージョンで警告を確認します。dataloading ハンドラーが、レンダー時の警告を発生させずに別のコンポーネントの state を更新できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 8.5k
- フォーク
- 1.3k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
visgl/react-map-gl のほかの issue
-
DEFAULT_SETTINGS.maxBounds in @vis.gl/react-maplibre has 360° longitude span, triggers maplibre-gl-js#6148 crash via _updateSettings fallback再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
visgl/react-map-gl#2591 · コメント 2 件 ·
-
[Bug] Mapbox geocoder example crashes: "i is not a function"対応中かも @yuiseki が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
visgl/react-map-gl#2628 ·
-
[Bug] Scroll zoom stops short of maxZoom in controlled mode with MapLibre対応中かも @sviat-barbutsa が 33 日前に担当しました。 オープンbug
難易度 3/5 半日 初心者へのやさしさ 74/100
visgl/react-map-gl#2626 ·
-
[Bug] reuseMaps: Mapbox.reuse() infinite-loops (tab freeze) when the recycled map's container is the mount container対応中かも @mikeyfarina が 82 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
visgl/react-map-gl#2613 ·
-
feature
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
visgl/react-map-gl#2603 · リアクション 1 件 ·
visgl/react-map-gl の issue をすべて見る
似ている issue
-
accessibility area:ci ci-test level:low priority:high type:test
難易度 2/5 1〜3時間 初心者へのやさしさ 71/100
skytuhua-org/Gen-V1#3132 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
drmrd/vernacular#1238 ·
メンテナーはふだん 1 日以内に返信
-
question
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
enhancement migration-prioritized
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Hudson-Pufferfish/local-party-console#136 ·
メンテナーはふだん 1 日以内に返信
-
priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信