Skip to content

Commit 728368c

Browse files
authored
fix: Camera onTrackUserLocationChange null value (#1113)
1 parent cfb0a1b commit 728368c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

ios/components/camera/MLRNCameraComponentView.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ - (void)prepareView {
4242
__typeof__(self) strongSelf = weakSelf;
4343

4444
if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
45+
NSString *trackUserLocation = event[@"trackUserLocation"];
46+
4547
facebook::react::MLRNCameraEventEmitter::OnTrackUserLocationChange eventStruct{
46-
[event[@"trackUserLocation"] UTF8String],
48+
[trackUserLocation isKindOfClass:[NSString class]]
49+
? folly::dynamic([trackUserLocation UTF8String])
50+
: folly::dynamic(nullptr),
4751
};
4852
std::dynamic_pointer_cast<const facebook::react::MLRNCameraEventEmitter>(
4953
strongSelf->_eventEmitter)

src/components/camera/Camera.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export interface CameraRef {
191191
export type TrackUserLocation = "default" | "heading" | "course";
192192

193193
export type TrackUserLocationChangeEvent = {
194-
trackUserLocation?: TrackUserLocation;
194+
trackUserLocation: TrackUserLocation | null;
195195
};
196196

197197
export type CameraProps = BaseProps &
@@ -299,11 +299,7 @@ export const Camera = memo(
299299
maxZoom={maxZoom}
300300
maxBounds={maxBounds}
301301
trackUserLocation={trackUserLocation}
302-
onTrackUserLocationChange={
303-
onTrackUserLocationChange as (
304-
event: NativeSyntheticEvent<{ trackUserLocation?: string }>,
305-
) => void
306-
}
302+
onTrackUserLocationChange={onTrackUserLocationChange}
307303
/>
308304
);
309305
},

src/components/camera/CameraNativeComponent.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
type ViewProps,
66
} from "react-native";
77

8+
import type { UnsafeMixed } from "../../types/codegen/UnsafeMixed";
9+
810
// START: NativeCameraStop
911
type NativeViewPadding = {
1012
top?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
@@ -36,7 +38,10 @@ type NativeCameraStop = NativeViewState & {
3638
type NativeTrackUserLocationMode = "none" | "default" | "heading" | "course";
3739

3840
type TrackUserLocationChangeEvent = {
39-
trackUserLocation?: string;
41+
trackUserLocation: UnsafeMixed<Exclude<
42+
NativeTrackUserLocationMode,
43+
"none"
44+
> | null>;
4045
};
4146

4247
export interface NativeProps extends ViewProps {

0 commit comments

Comments
 (0)