[Bug] Warning: useLayoutEffect does nothing on the server
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- nextjs, react, typescript
調査の方向性
dist/index.modern.mjs:805 の SSR スタックトレースで特定された Map エントリーポイントから開始し、サーバーサイドレンダリングされる NextJS アプリで警告を再現します。そのエントリーポイントをパッケージのソースまでたどります; サーバーサイドレンダリングで useLayoutEffect 警告が出力されなくなり、クライアント側の動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description
After installing the react-google-maps package we started getting the following error:
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.
2024-05-24T18:49:02.004220106Z at Map (file:///app/node_modules/@vis.gl/react-google-maps/dist/index.modern.mjs:805:5)
In our own project we used something like this to prevent this warning issue.
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect
This means that it will use useLayoutEffect normally, but during Server Side Rendering it will use useEffect
Steps to Reproduce
Use react-google-maps inside of a NextJS project.
Environment
- Library version: 0.11.0
- Google maps version: weekly
- Browser and Version: Chrome
- OS: Alpine Linux
Logs
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.
2024-05-24T18:49:02.004220106Z at Map (file:///app/node_modules/@vis.gl/react-google-maps/dist/index.modern.mjs:805:5)
- 主要言語
- TypeScript
- スター
- 2k
- フォーク
- 195
- 平均マージ
- 6時間 26分
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
visgl/react-google-maps のほかの issue
-
Polygon / Polyline: edits after a controlled `paths` update never reach `onPathsChanged`対応中かも @anubhavlal07 が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
visgl/react-google-maps#1120 ·
メンテナーはふだん 1 日以内に返信
-
google maps issue
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
visgl/react-google-maps#1080 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug needs more info
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#1039 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
visgl/react-google-maps#918 · コメント 9 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
visgl/react-google-maps#905 ·
メンテナーはふだん 1 日以内に返信
visgl/react-google-maps の 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 日以内に返信