Skip to content

Commit b6aac63

Browse files
authored
Merge pull request #614 from draftbit/youssef/ext-33-maps-shows-a-loading-icon-and-an-error2
Fixed Maps Script Error + Corrupt Package Issue
2 parents 78caa51 + a1f3226 commit b6aac63

File tree

12 files changed

+85
-56
lines changed

12 files changed

+85
-56
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ jobs:
9292
curl "https://snackager.expo.io/bundle/@draftbit/maps@"$newversion"?version_snackager=true&platforms=ios,android,web&bypassCache=true";
9393
working-directory: packages/ui
9494

95-
9695
- name: Release to Snack
9796
if: github.event_name != 'pull_request'
9897
run: |

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"crosslink": "lerna link",
1717
"format": "prettier --write .",
1818
"lint": "eslint \"**/*.{ts,tsx}\"",
19-
"build": "lerna run prepare",
19+
"build": "lerna run prepack",
2020
"release": "lerna publish",
2121
"example:snack": "ts-node --transpile-only scripts/upload-to-snack.ts",
2222
"clean": "lerna run clean",
@@ -52,7 +52,7 @@
5252
"patch-package": "^6.4.7",
5353
"postinstall-postinstall": "^2.1.0",
5454
"prettier": "^2.7.1",
55-
"react-native-builder-bob": "^0.20.3",
55+
"react-native-builder-bob": "^0.20.4",
5656
"rimraf": "^3.0.2",
5757
"ts-node": "^10.0.0",
5858
"typescript": "~4.7.4",

packages/core/package.json

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"!**/__mocks__"
1616
],
1717
"scripts": {
18-
"prepare": "bob build",
1918
"clean": "rimraf lib",
20-
"clean:modules": "rimraf node_modules"
19+
"clean:modules": "rimraf node_modules",
20+
"prepack": "bob build"
2121
},
2222
"keywords": [
2323
"react-native",
@@ -75,22 +75,11 @@
7575
"@types/lodash.tonumber": "^4.0.6"
7676
},
7777
"react-native-builder-bob": {
78-
"declarationMap": false,
7978
"source": "src",
8079
"output": "lib",
8180
"targets": [
82-
[
83-
"commonjs",
84-
{
85-
"sourceMaps": false
86-
}
87-
],
88-
[
89-
"module",
90-
{
91-
"sourceMaps": false
92-
}
93-
],
81+
"commonjs",
82+
"module",
9483
[
9584
"typescript",
9685
{
@@ -99,5 +88,9 @@
9988
}
10089
]
10190
]
102-
}
91+
},
92+
"eslintIgnore": [
93+
"node_modules/",
94+
"lib/"
95+
]
10396
}

packages/maps/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"!**/__mocks__"
1616
],
1717
"scripts": {
18-
"prepare": "bob build",
1918
"clean": "rimraf lib",
20-
"clean:modules": "rimraf node_modules"
19+
"clean:modules": "rimraf node_modules",
20+
"prepack": "bob build"
2121
},
2222
"keywords": [
2323
"react-native",
@@ -44,7 +44,6 @@
4444
"react-native-maps": "0.31.1"
4545
},
4646
"react-native-builder-bob": {
47-
"declarationMap": false,
4847
"source": "src",
4948
"output": "lib",
5049
"targets": [
@@ -68,5 +67,9 @@
6867
}
6968
]
7069
]
71-
}
70+
},
71+
"eslintIgnore": [
72+
"node_modules/",
73+
"lib/"
74+
]
7275
}

packages/native/package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
"source": "src/index.tsx",
1010
"files": [
1111
"src",
12-
"lib"
12+
"lib",
13+
"!**/__tests__",
14+
"!**/__fixtures__",
15+
"!**/__mocks__"
1316
],
1417
"scripts": {
15-
"prepare": "bob build",
1618
"clean": "rimraf lib",
17-
"clean:modules": "rimraf node_modules"
19+
"clean:modules": "rimraf node_modules",
20+
"prepack": "bob build"
1821
},
1922
"keywords": [
2023
"react-native",
@@ -47,7 +50,6 @@
4750
"react-native-webview": "11.23.0"
4851
},
4952
"react-native-builder-bob": {
50-
"declarationMap": false,
5153
"source": "src",
5254
"output": "lib",
5355
"targets": [
@@ -71,5 +73,9 @@
7173
}
7274
]
7375
]
74-
}
76+
},
77+
"eslintIgnore": [
78+
"node_modules/",
79+
"lib/"
80+
]
7581
}

packages/types/package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
"source": "src/index.ts",
1010
"files": [
1111
"src",
12-
"lib"
12+
"lib",
13+
"!**/__tests__",
14+
"!**/__fixtures__",
15+
"!**/__mocks__"
1316
],
1417
"scripts": {
15-
"prepare": "bob build",
1618
"clean": "rimraf lib",
17-
"clean:modules": "rimraf node_modules"
19+
"clean:modules": "rimraf node_modules",
20+
"prepack": "bob build"
1821
},
1922
"keywords": [
2023
"react-native",
@@ -36,7 +39,6 @@
3639
},
3740
"homepage": "https://github.com/draftbit/react-native-jigsaw#readme",
3841
"react-native-builder-bob": {
39-
"declarationMap": false,
4042
"source": "src",
4143
"output": "lib",
4244
"targets": [
@@ -60,5 +62,9 @@
6062
}
6163
]
6264
]
63-
}
65+
},
66+
"eslintIgnore": [
67+
"node_modules/",
68+
"lib/"
69+
]
6470
}

packages/ui/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"draftbit-ui.podspec"
2020
],
2121
"scripts": {
22-
"prepare": "bob build",
2322
"clean": "rimraf lib",
24-
"clean:modules": "rimraf node_modules"
23+
"clean:modules": "rimraf node_modules",
24+
"prepack": "bob build"
2525
},
2626
"keywords": [
2727
"react-native",
@@ -47,7 +47,6 @@
4747
"@draftbit/native": "46.10.2"
4848
},
4949
"react-native-builder-bob": {
50-
"declarationMap": false,
5150
"source": "src",
5251
"output": "lib",
5352
"targets": [
@@ -71,5 +70,9 @@
7170
}
7271
]
7372
]
74-
}
73+
},
74+
"eslintIgnore": [
75+
"node_modules/",
76+
"lib/"
77+
]
7578
}

packages/web-maps/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"!**/__mocks__"
1616
],
1717
"scripts": {
18-
"prepare": "bob build",
1918
"clean": "rimraf lib",
20-
"clean:modules": "rimraf node_modules"
19+
"clean:modules": "rimraf node_modules",
20+
"prepack": "bob build"
2121
},
2222
"keywords": [
2323
"react-native",
@@ -66,5 +66,9 @@
6666
}
6767
]
6868
]
69-
}
69+
},
70+
"eslintIgnore": [
71+
"node_modules/",
72+
"lib/"
73+
]
7074
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react";
2+
import { useJsApiLoader } from "./ReactGoogleMaps";
3+
4+
interface MapScriptLoaderProps {
5+
apiKey: string;
6+
}
7+
8+
const MapScriptLoader: React.FC<
9+
React.PropsWithChildren<MapScriptLoaderProps>
10+
> = ({ children, apiKey }) => {
11+
const { isLoaded } = useJsApiLoader({
12+
id: "google-map-script",
13+
googleMapsApiKey: apiKey,
14+
});
15+
16+
return <>{isLoaded ? children : null}</>;
17+
};
18+
19+
export default MapScriptLoader;

packages/web-maps/src/components/MapView.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from "react";
2-
import { GoogleMap, Marker, LoadScript } from "./ReactGoogleMaps";
2+
import { GoogleMap, Marker } from "./ReactGoogleMaps";
33
import NoApiKey from "./NoApiKey";
4+
import MapScriptLoader from "./MapScriptLoader";
45
import { MapViewProps } from "@draftbit/types";
56
import { StyleSheet } from "react-native";
67

@@ -105,21 +106,16 @@ class MapView extends React.Component<
105106

106107
const { lat, lng, userLocation, zoom } = this.state;
107108

108-
if (!LoadScript || !GoogleMap || !Marker) {
109+
if (!GoogleMap || !Marker) {
109110
return null;
110111
}
111112

112113
if (!apiKey) {
113114
return <NoApiKey />;
114115
}
115116

116-
//Follows how source library checks for loaded script (https://github.com/JustFly1984/react-google-maps-api/blob/develop/packages/react-google-maps-api/src/LoadScript.tsx)
117-
const isScriptLoaded = !!(window.google && window.google.maps);
118-
119-
const TopLevelContainer = isScriptLoaded ? React.Fragment : LoadScript;
120-
121117
return (
122-
<TopLevelContainer googleMapsApiKey={apiKey}>
118+
<MapScriptLoader apiKey={apiKey}>
123119
<GoogleMap
124120
mapContainerStyle={StyleSheet.flatten(style) as React.CSSProperties}
125121
center={{
@@ -165,7 +161,7 @@ class MapView extends React.Component<
165161
})
166162
: children}
167163
</GoogleMap>
168-
</TopLevelContainer>
164+
</MapScriptLoader>
169165
);
170166
}
171167
}

0 commit comments

Comments
 (0)