Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: render Mapbox.MapView when access token is correctly set #44767

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/MapView/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
const currentPosition = userLocation ?? initialLocation;
const [userInteractedWithMap, setUserInteractedWithMap] = useState(false);
const shouldInitializeCurrentPosition = useRef(true);
const [isAccessTokenSet, setIsAccessTokenSet] = useState(false);

// Determines if map can be panned to user's detected
// location without bothering the user. It will return
Expand Down Expand Up @@ -138,7 +139,12 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
}, [navigation]);

useEffect(() => {
setAccessToken(accessToken);
setAccessToken(accessToken).then((token) => {
if (!token) {
return;
}
setIsAccessTokenSet(true);
});
}, [accessToken]);

const setMapIdle = (e: MapState) => {
Expand Down Expand Up @@ -198,7 +204,7 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
const initCenterCoordinate = useMemo(() => (interactive ? centerCoordinate : undefined), [interactive, centerCoordinate]);
const initBounds = useMemo(() => (interactive ? undefined : waypointsBounds), [interactive, waypointsBounds]);

return !isOffline && !!accessToken && !!defaultSettings ? (
return !isOffline && isAccessTokenSet && !!defaultSettings ? (
<View style={[style, !interactive ? styles.pointerEventsNone : {}]}>
<Mapbox.MapView
style={{flex: 1}}
Expand Down
Loading