Skip to content

Commit

Permalink
Merge pull request #717 from City-of-Helsinki/fix/use-mobile-hook
Browse files Browse the repository at this point in the history
Call updateState to ensure useMobile hook to initialize state
  • Loading branch information
minevala authored May 30, 2022
2 parents 3996614 + be2dd9b commit fcc316a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/react/src/hooks/useMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const useMobile = (): boolean => {
const updateState = () => setIsMobile(checkIfMobile());

window.addEventListener('resize', updateState);
updateState();

return () => window.removeEventListener('resize', updateState);
}, []);
Expand Down

0 comments on commit fcc316a

Please sign in to comment.