Skip to content

fix(Viewport): allow transitionTo without an explicit transition on iOS#4247

Merged
mfazekas merged 1 commit into
mainfrom
fix/viewport-transition-optional-ios
Jul 5, 2026
Merged

fix(Viewport): allow transitionTo without an explicit transition on iOS#4247
mfazekas merged 1 commit into
mainfrom
fix/viewport-transition-optional-ios

Conversation

@mfazekas

@mfazekas mfazekas commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #4226

Viewport.transitionTo(state, transition?) types the transition as optional, and Android already handles a missing transition (falls back to Mapbox's default). On iOS, though, toTransition guarded on the transition's kind and returned nil when it was absent, so transitionTo aborted with a non-descriptive Mapbox [error] no kind found in state and never ran the transition.

This defaults to the default transition when no kind is provided, matching Android and the TypeScript types.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

Screenshot OR Video

Verified on the iOS example (New Arch, Mapbox v11). Before the fix, calling transitionTo({ kind: 'followPuck' }) with no transition logged:

Mapbox [error] no kind found in state
Mapbox [error] unable to parse transition in RNMBXViewport.transitionTo

After the fix the transition runs and resolves (transitionTo completed: true); the camera transitions to follow the puck.

Component to reproduce the issue you're fixing

Reproducer
import React, { useEffect, useRef } from 'react';
import { MapView, Viewport } from '@rnmapbox/maps';

function BugReport() {
  const viewportRef = useRef<Viewport>(null);

  useEffect(() => {
    // transition is optional per the TS types; on iOS this previously
    // failed with "no kind found in state" instead of using the default.
    viewportRef.current?.transitionTo({ kind: 'followPuck' });
  }, []);

  return (
    <MapView style={{ flex: 1 }}>
      <Viewport ref={viewportRef} />
    </MapView>
  );
}

transitionTo's transition arg is optional in TypeScript, but on iOS the
missing kind hit a guard in toTransition and aborted with 'no kind found
in state', so the transition never ran. Default to the 'default'
transition when no kind is provided, matching Android and the TS types.

Fixes #4226
@mfazekas mfazekas merged commit 1af8d58 into main Jul 5, 2026
7 checks passed
@mfazekas mfazekas deleted the fix/viewport-transition-optional-ios branch July 5, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Viewport transition is non-optional on iOS

1 participant