Skip to content

Commit 08d0ac1

Browse files
committed
Logic tweak
1 parent 2c46802 commit 08d0ac1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

modules/Media.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ class Media extends React.Component {
2626
this.setState({ matches: this.mediaQueryList.matches })
2727

2828
componentWillMount() {
29+
if (typeof window !== 'object')
30+
return
31+
2932
let { query } = this.props
3033

3134
if (typeof query !== 'string')
3235
query = json2mq(query)
3336

34-
if (typeof window === 'object') {
35-
this.mediaQueryList = window.matchMedia(query)
36-
this.mediaQueryList.addListener(this.updateMatches)
37-
this.updateMatches()
38-
}
37+
this.mediaQueryList = window.matchMedia(query)
38+
this.mediaQueryList.addListener(this.updateMatches)
39+
this.updateMatches()
3940
}
4041

4142
componentWillUnmount() {

0 commit comments

Comments
 (0)