Cannot find namespace 'google'.
@amuramoto đang làm issue này rồi.
Từ ngày 12/7/2022.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Operating system
macOS 12.04
Browser Version
Firefox 100.0.2
How severe is the bug?
moderate
Bug description
This bug is about the code excerpt from https://developers.google.com/maps/documentation/javascript/react-map#add-map
Using the given code block (see below), will lead to
Cannot find namespace 'google'. and Property 'google' does not exist on type 'Window & typeof globalThis'. The imports linked in this repository does also not solve the problem.
const ref = React.useRef<HTMLDivElement>(null);
const [map, setMap] = React.useState<google.maps.Map>();
React.useEffect(() => {
if (ref.current && !map) {
setMap(new window.google.maps.Map(ref.current, {}));
}
}, [ref, map]);
Steps to reproduce
Follow the steps on https://developers.google.com/maps/documentation/javascript/react-map#typescript
Console log output
Uncaught TypeError: window.google is undefined
Source code as suggested by the guide
import React from 'react';
import { Wrapper, Status } from '@googlemaps/react-wrapper';
export const Map: React.FC<{}> = () => {
const ref = React.useRef<HTMLDivElement>(null);
const [map, setMap] = React.useState<google.maps.Map>();
React.useEffect(() => {
if (ref.current && !map) {
setMap(new window.google.maps.Map(ref.current, {}));
}
}, [ref, map]);
return <div ref={ref} />;
};
export const MyMap: React.FC = () => {
return (
<>
<Map />
</>
);
};
- Ngôn ngữ chính
- TypeScript
- Star
- 804
- Fork
- 826
- 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 googlemaps/js-samples
-
Advanced Markers Animation Unused VariableCó thể đã có người làm @treckstar đã nhận 832 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
googlemaps/js-samples#1794 ·
-
DriverĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 5/100
googlemaps/js-samples#1940 ·
-
Exposed api key in documentationĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
googlemaps/js-samples#1932 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
googlemaps/js-samples#1914 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
googlemaps/js-samples#1827 · 1 bình luận ·
Tất cả issue của googlemaps/js-samples
Issue tương tự
-
Bug: Cloudflare Pages static _redirects identity rule causes RSC Flight to reload as HTMLCó thể đã có người làm @Donvero đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Mantitup-Org/vista#210 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
simstudioai/sim#9831 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status: waiting for maintainer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
mui/material-ui#49751 ·
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 88/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
diplodoc-platform/transform#1184 ·
Maintainer thường phản hồi trong vòng 1 ngày