From 6b377622e529edeb321ef4191cbcc9b0627e9235 Mon Sep 17 00:00:00 2001 From: landabaso Date: Sat, 19 Nov 2016 09:48:01 +0100 Subject: [PATCH] Make sure it does not throw in SSR Make sure it does not throw in a SSR (Server Side Rendering) situation --- src/ResizeSensor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ResizeSensor.js b/src/ResizeSensor.js index af38c6e..e52aa1e 100755 --- a/src/ResizeSensor.js +++ b/src/ResizeSensor.js @@ -14,6 +14,10 @@ } }(this, function () { + //Make sure it does not throw in a SSR (Server Side Rendering) situation + if (typeof window === "undefined") { + return null; + } // Only used for the dirty checking, so the event callback count is limted to max 1 call per fps per sensor. // In combination with the event based resize sensor this saves cpu time, because the sensor is too fast and // would generate too many unnecessary events.