Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit 79c38f1

Browse files
committed
fix(block): add typeof window to pass gatsby build
1 parent 426b812 commit 79c38f1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/styled/ShareBlockAside.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,24 @@ class ShareBlockAside extends React.Component {
7171
};
7272

7373
componentDidMount() {
74-
this.setupObserver();
75-
this.setFixedButtonsTranslation();
76-
77-
window.addEventListener(
78-
'resize',
79-
debounce(this.setFixedButtonsTranslation, this.props.debounce),
80-
false
81-
);
74+
if (typeof window !== `undefined`) {
75+
this.setupObserver();
76+
this.setFixedButtonsTranslation();
77+
78+
window.addEventListener(
79+
'resize',
80+
debounce(this.setFixedButtonsTranslation, this.props.debounce),
81+
false
82+
);
83+
}
8284
}
8385

8486
componentWillUnmount() {
8587
// unobserve the targets
86-
for (var value of this.observerTargets) {
87-
this.observer.unobserve(value);
88+
if (typeof window !== `undefined`) {
89+
for (var value of this.observerTargets) {
90+
this.observer.unobserve(value);
91+
}
8892
}
8993
}
9094

0 commit comments

Comments
 (0)