Skip to content

Commit

Permalink
Finish feature/152
Browse files Browse the repository at this point in the history
  • Loading branch information
dlcastillop authored Dec 22, 2024
2 parents ed5cc7f + 72514b0 commit 951c231
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/hooks/js/useDeviceOrientation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ const orientationSubscribe = (cb) => {
};

const getOrientation = () => {
return {
type: window.screen.orientation.type,
angle: window.screen.orientation.angle
};
const { type, angle } = window.screen.orientation;
return JSON.stringify({ type, angle });
};

export const useDeviceOrientation = () =>
useSyncExternalStore(orientationSubscribe, getOrientation);
JSON.parse(useSyncExternalStore(orientationSubscribe, getOrientation));
8 changes: 3 additions & 5 deletions src/hooks/ts/useDeviceOrientation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ const orientationSubscribe = (cb: () => void) => {
};

const getOrientation = () => {
return {
type: window.screen.orientation.type,
angle: window.screen.orientation.angle
};
const { type, angle } = window.screen.orientation;
return JSON.stringify({ type, angle });
};

export const useDeviceOrientation = () =>
useSyncExternalStore(orientationSubscribe, getOrientation);
JSON.parse(useSyncExternalStore(orientationSubscribe, getOrientation));

0 comments on commit 951c231

Please sign in to comment.