Skip to content

Commit

Permalink
fix: useOrientation breaks in some devices
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich authored Feb 11, 2019
2 parents 07baffd + 77ebef5 commit d89bd54
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/useOrientation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ const useOrientation = (initialState: OrientationState = defaultState) => {
if (mounted) {
const {orientation} = screen as any;

if (!orientation) {
if (orientation) {
const {angle, type} = orientation;
setState({angle, type});
} else if (window.orientation) {
setState({
angle: window.orientation,
type: ''
});
} else {
setState(initialState);
}

const {angle, type} = orientation;
setState({angle, type});
}
};

Expand Down

0 comments on commit d89bd54

Please sign in to comment.