Skip to content

Commit

Permalink
improve react-native/expo support
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Sep 8, 2021
1 parent c810d65 commit 1fb706d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/app/src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
return this.userInfo(ctx);
},

userInfo(ctx) {
userInfo(ctx={}) {
const { user, config, csrftoken } = this.getState(),
pageConf = (ctx.router_info && ctx.router_info.page_config) || {},
wqPageConf =
Expand Down
2 changes: 1 addition & 1 deletion packages/map-gl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"react-mapbox-gl-draw": "^2.0.4"
},
"peerDependencies": {
"@react-native-mapbox-gl/maps": "^8.1.0-rc.2"
"@react-native-mapbox-gl/maps": "^8.3.0"
},
"devDependencies": {
"@wq/model": "^1.3.0-beta.1",
Expand Down
6 changes: 4 additions & 2 deletions packages/map-gl/src/basemaps/Tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default function Tile() {
return null;
}

Tile.asBasemapStyle = basemap => {
export function asBasemapStyle(basemap) {
const urls = [];
if (basemap.url.match('{s}')) {
(basemap.subdomains || ['a', 'b', 'c']).forEach(s =>
Expand All @@ -29,4 +29,6 @@ Tile.asBasemapStyle = basemap => {
}
]
};
};
}

Tile.asBasemapStyle = asBasemapStyle;
7 changes: 6 additions & 1 deletion packages/map-gl/src/basemaps/Tile.native.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export default function FIXME() {
import { asBasemapStyle } from './Tile.js';

export default function Tile() {
// Handled with style= prop in root Map
return null;
}

Tile.asBasemapStyle = asBasemapStyle;
6 changes: 5 additions & 1 deletion packages/map-gl/src/basemaps/VectorTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ export default function VectorTile() {
return null;
}

VectorTile.asBasemapStyle = basemap => basemap.url;
export function asBasemapStyle(basemap) {
return basemap.style || basemap.url;
}

VectorTile.asBasemapStyle = asBasemapStyle;
4 changes: 3 additions & 1 deletion packages/map-gl/src/basemaps/VectorTile.native.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { asBasemapStyle } from './VectorTile.js';

export default function VectorTile() {
// Handled with style= prop in root Map
return null;
}

VectorTile.asBasemapStyle = basemap => basemap.url;
VectorTile.asBasemapStyle = asBasemapStyle;
8 changes: 5 additions & 3 deletions packages/map-gl/src/components/Map.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export default function Map({
const [[xmin, ymin], [xmax, ymax]] = initBounds;
return { sw: [xmin, ymin], ne: [xmax, ymax] };
}, [initBounds]),
style = findBasemapStyle(children);

style = findBasemapStyle(children),
styleURL = typeof style === 'string' ? style : null,
styleJSON = typeof style === 'string' ? null : JSON.stringify(style);
const mapRef = React.useRef(),
setMapRef = React.useCallback(ref => {
mapRef.current = ref;
Expand All @@ -53,7 +54,8 @@ export default function Map({

return (
<MapboxGL.MapView
styleURL={style}
styleURL={styleURL}
styleJSON={styleJSON}
ref={setMapRef}
rotateEnabled={rotateEnabled}
pitchEnabled={pitchEnabled}
Expand Down
2 changes: 1 addition & 1 deletion packages/router/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ router.render = function (context, refresh) {
if (site_title && title !== site_title) {
title = `${title} - ${site_title}`;
}
document.title = title;
if (window.document) window.document.title = title;

return router.store.dispatch({
type: RENDER,
Expand Down

0 comments on commit 1fb706d

Please sign in to comment.