Fix function to determine mobile viewport for SSR

This commit is contained in:
Mathias Schopmans
2017-04-03 16:16:40 +02:00
parent b14d7ab319
commit 6e4bcec471

View File

@@ -35,6 +35,9 @@ const messages = {
export const translate = (key) => (messages[key] || '-');
export function isMobileViewport() {
// return false for server side rendering
if (typeof window == 'undefined') return false;
const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
return width < 1200;
}