Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 2507b4b

Browse files
committed
refactor(userMap): mv g2 script into userMap container
1 parent 2262a39 commit 2507b4b

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

containers/UsersThread/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import dynamic from 'next/dynamic'
99

1010
import { connectStore, buildLog } from '@utils'
1111

12+
import { useScript } from '@components/Hooks'
13+
1214
import NumDashboard from './NumDashboard'
1315
import MapLoading from './MapLoading'
1416

@@ -26,6 +28,11 @@ const GeoMapSSR = dynamic({
2628
})
2729

2830
const UsersThreadContainer = ({ usersThread }) => {
31+
/* load g2 from CDN, it's too big for dynamic import, and i am poor ..' */
32+
const [g2ScriptLoaded] = useScript(
33+
'https://a.alipayobjects.com/g/datavis/g2/2.3.13/index.js'
34+
)
35+
2936
useInit(usersThread)
3037

3138
const {
@@ -36,7 +43,7 @@ const UsersThreadContainer = ({ usersThread }) => {
3643
showNums,
3744
} = usersThread
3845

39-
const ready = GeoMapSSR !== null && !geoDataLoading
46+
const ready = g2ScriptLoaded && GeoMapSSR !== null && !geoDataLoading
4047

4148
return (
4249
<Wrapper>

pages/_document.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ export default class DocumentPage extends Document {
4848
content="width=device-width, initial-scale=1, viewport-fit=cover"
4949
/>
5050

51-
{/* load g2 from CDN, it's too big for dynamic import, and i am poor ..' */}
52-
<script
53-
async
54-
src="https://a.alipayobjects.com/g/datavis/g2/2.3.13/index.js"
55-
/>
56-
{/* https://cps-oss.oss-cn-shanghai.aliyuncs.com/antd-3.8.4-mini.css */}
5751
<link href="/antd-3.8.4-mini.css" rel="stylesheet" />
5852
<link
5953
href="https://fonts.googleapis.com/css?family=Orbitron"
@@ -63,9 +57,7 @@ export default class DocumentPage extends Document {
6357

6458
<script
6559
async
66-
src={`https://www.googletagmanager.com/gtag/js?id=${
67-
process.env.GA_TRACING_ID
68-
}`}
60+
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GA_TRACING_ID}`}
6961
/>
7062
<script
7163
dangerouslySetInnerHTML={{

0 commit comments

Comments
 (0)