Skip to content

Commit 520c969

Browse files
landabasomarcj
authored andcommitted
Make sure it does not throw in SSR (#137)
Make sure it does not throw in a SSR (Server Side Rendering) situation
1 parent 4f0b878 commit 520c969

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ResizeSensor.js

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
}
1515
}(this, function () {
1616

17+
//Make sure it does not throw in a SSR (Server Side Rendering) situation
18+
if (typeof window === "undefined") {
19+
return null;
20+
}
1721
// Only used for the dirty checking, so the event callback count is limted to max 1 call per fps per sensor.
1822
// In combination with the event based resize sensor this saves cpu time, because the sensor is too fast and
1923
// would generate too many unnecessary events.

0 commit comments

Comments
 (0)