Skip to content

Commit 05ecb02

Browse files
author
Ray Cohen
committed
dont reference window until after we confirm it exists with typeof
1 parent f187c00 commit 05ecb02

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/Media.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ class Media extends React.Component {
3030

3131
componentWillMount() {
3232
let { query } = this.props;
33-
const targetWindow = this.props.targetWindow || window;
3433

35-
if (typeof targetWindow !== "object") return;
34+
if (typeof window !== "object") return;
35+
36+
const targetWindow = this.props.targetWindow || window;
3637

3738
if (!targetWindow.matchMedia) {
3839
throw new Error(

0 commit comments

Comments
 (0)