[Feat] Add SSR support or safe usage of AdvancedMarker and DOM-dependent components
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- react, typescript
調査の方向性
まず、issue で言及されている AdvancedMarker、MapControl、APIProvider のエントリーポイントを読み、SSR と hydration の構成でそれらの動作を再現します。SSR セーフな動作とクライアント専用の動作のうち、どれをサポートするかを決定し、サーバーレンダリングと hydration のカバレッジを追加して、SSR フレームワークで推奨される使用方法をドキュメント化します。
索引モデルが issue の本文から書いたものです。
説明
Target Use Case
We are using @vis.gl/react-google-maps in a project that renders pages using server-side rendering, and then hydrates them on the client.
However, the current package assumes a browser environment by default — for example, components like AdvancedMarker use ReactDOM.createPortal and interact with the DOM, which causes SSR crashes when the page is pre-rendered on the server.
We are currently forced to wrap these components in client-only guards like:
if (typeof window !== 'undefined') {
return <AdvancedMarker ... />;
}
const [isClient, setIsClient] = useState(false);
useEffect(() => {
setIsClient(true);
}, []);
return isClient ? <AdvancedMarker ... /> : null;
It would be helpful if the library could offer a built-in way to make components like AdvancedMarker SSR-safe or optionally lazy-loadable so that SSR apps don’t crash or require workarounds.
Adding SSR support (or safe lazy loading) would benefit anyone using React frameworks like Next.js, Remix, or custom SSR setups that render Google Maps on the server and hydrate them client-side.
This is especially important for:
- SEO-sensitive apps
- Performance-focused web apps
- Sites with server-rendered landing pages that contain maps
It would also reduce the need for wrapping AdvancedMarker and other DOM-dependent components in custom client-only guards, simplifying code and avoiding errors during hydration.
Proposal
- Provide a
ssr: falseorclientOnly: trueprop on components likeAdvancedMarkerorAPIProviderthat tells them to skip rendering during SSR. - Internally guard browser-only operations in DOM-based components like
AdvancedMarkerby checkingtypeof window !== 'undefined'before callingReactDOM.createPortal. - Document a recommended pattern or wrapper component for SSR users, such as a ClientOnly wrapper like:
function ClientOnly({ children }) {
const [isClient, setIsClient] = useState(false);
useEffect(() => setIsClient(true), []);
return isClient ? children : null;
}
- Optionally provide a utility from the package itself:
import { ClientOnly } from '@vis.gl/react-google-maps';
// or
<AdvancedMarker ssr={false} ... />
Even a small guard inside AdvancedMarker (as well as MapControl) would prevent runtime crashes and improve compatibility across frameworks.
- 主要言語
- TypeScript
- スター
- 1.9k
- フォーク
- 195
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
visgl/react-google-maps のほかの issue
-
google maps issue
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
visgl/react-google-maps#1080 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug needs more info
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#1039 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
visgl/react-google-maps#918 · コメント 9 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
visgl/react-google-maps#905 ·
メンテナーはふだん 2 日以内に返信
-
google maps issue
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#889 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
visgl/react-google-maps の issue をすべて見る
似ている issue
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
inu-appcenter/memorIN-frontend#106 ·
メンテナーはふだん 1 日以内に返信
-
kind/bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 7 日以内に返信
-
[Bug] @deck.gl/arcgis dist import resolves to unpublished @deck.gl/core source path (9.3.11, 9.4.0)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
CSCfi/sd-search-ui#145 ·
メンテナーはふだん 1 日以内に返信
-
Add: Cbeebies pl SDオープンcheck:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信