Skip to content
This repository was archived by the owner on Feb 19, 2022. It is now read-only.

Commit f6df859

Browse files
committed
Fix android inconsistency
1 parent 66cde68 commit f6df859

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/getCurrentOrientation.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ const updateCurrentOrientation = (orientation: string): void => {
1212
_currentOrientation = orientation === 'PORTRAIT' ? 'portrait' : 'landscape';
1313
};
1414

15-
Orientation.getOrientation(updateCurrentOrientation);
15+
Orientation.getOrientation((orientation) => {
16+
// workaround for API inconsistency
17+
// https://github.com/walmartlabs/react-native-orientation-listener/issues/10
18+
if (typeof orientation === 'object' && 'orientation' in orientation) {
19+
updateCurrentOrientation(orientation.orientation);
20+
} else {
21+
updateCurrentOrientation(orientation);
22+
}
23+
});
1624

17-
Orientation.addListener(({ orientation }) => updateCurrentOrientation(orientation));
25+
Orientation.addListener(({ orientation }) => {
26+
updateCurrentOrientation(orientation);
27+
});

0 commit comments

Comments
 (0)