Skip to content

Commit 6785cff

Browse files
authored
stop & defaultStop race stop (#4040)
* stop & defaultStop race stop * fix tests
1 parent ea99257 commit 6785cff

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

__tests__/components/Camera.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('Camera', () => {
3131
test('defaults are set', () => {
3232
const result = render(<Camera />);
3333
const { props } = result.queryByTestId('Camera');
34-
expect(props.stop).toStrictEqual({});
34+
expect(props.stop).toStrictEqual(null);
3535
});
3636
test('set location by center', () => {
3737
const result = render(

android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class RNMBXCameraManager(private val mContext: ReactApplicationContext, val view
3636
override fun setStop(camera: RNMBXCamera, map: Dynamic) {
3737
if (!map.isNull) {
3838
val mapValue = map.asMap()
39-
if (mapValue == null) {
40-
Logger.e("RNMBXCameraManager", "stop map is null")
39+
if (mapValue == null || mapValue.keySetIterator().hasNextKey().not()) {
40+
Logger.e("RNMBXCameraManager", "stop map is null or empty")
4141
return
4242
}
4343
val stop = fromReadableMap(mContext, mapValue, null)

android/src/main/java/com/rnmapbox/rnmbx/utils/PropertyChanges.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.rnmapbox.rnmbx.utils
22

33
/**
44
* This mechanism allows to separate property updates from application of property updates. Usefull for delaying the propery updates
5-
* because the object is not yet created for example. Or to apply multiple propery changes at once.
5+
* because the object is not yet created for example. Or to apply multiple property changes at once.
66
*
77
* @sample
88
*

src/components/Camera.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,17 @@ export const Camera = memo(
388388
}, [defaultSettings, buildNativeStop]);
389389

390390
const nativeStop = useMemo(() => {
391+
if (
392+
centerCoordinate === undefined &&
393+
bounds === undefined &&
394+
heading === undefined &&
395+
pitch === undefined &&
396+
zoomLevel === undefined &&
397+
padding === undefined
398+
) {
399+
return null;
400+
}
401+
391402
return buildNativeStop({
392403
type: 'CameraStop',
393404
centerCoordinate,

0 commit comments

Comments
 (0)