Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
toddkao committed Jan 24, 2025
1 parent 999a5fd commit b6b9b87
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/widget/src/hooks/useIsMobileScreenSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ export const MAX_MOBILE_SCREEN_WIDTH = 767;

export const useIsMobileScreenSize = () => {
const [isMobileScreenSize, setIsMobileScreenSize] = useState(
window.innerWidth <= MAX_MOBILE_SCREEN_WIDTH,
window?.innerWidth <= MAX_MOBILE_SCREEN_WIDTH,
);

useEffect(() => {
const handleResize = () => {
const isMobileScreenSize = window.innerWidth <= MAX_MOBILE_SCREEN_WIDTH;
const isMobileScreenSize = window?.innerWidth <= MAX_MOBILE_SCREEN_WIDTH;
setIsMobileScreenSize(isMobileScreenSize);
};

handleResize();

window.addEventListener("resize", handleResize);
window?.addEventListener("resize", handleResize);

return () => {
window.removeEventListener("resize", handleResize);
window?.removeEventListener("resize", handleResize);
};
}, []);
return isMobileScreenSize;
Expand Down

0 comments on commit b6b9b87

Please sign in to comment.