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

Commit d78e8bd

Browse files
committed
fix(block): add more window !== undefind conditions
1 parent 79c38f1 commit d78e8bd

File tree

7 files changed

+53
-32
lines changed

7 files changed

+53
-32
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"normalize.css": "^8.0.0",
2626
"prismjs": "^1.14.0",
2727
"react-addons-perf": "^15.4.2",
28-
"react-custom-share": "^0.4.4",
28+
"react-custom-share": "^0.4.6",
2929
"react-helmet": "^5.2.0",
3030
"react-icons": "^2.2.7",
3131
"react-lorem-component": "^0.13.0",

docs/yarn.lock

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9462,13 +9462,12 @@ react-addons-perf@^15.4.2:
94629462
fbjs "^0.8.4"
94639463
object-assign "^4.1.0"
94649464

9465-
react-custom-share@^0.4.4:
9466-
version "0.4.4"
9467-
resolved "https://registry.yarnpkg.com/react-custom-share/-/react-custom-share-0.4.4.tgz#b8f36cc04b8164d356e6b4cda58b5c0577a0f104"
9465+
react-custom-share@^0.4.6:
9466+
version "0.4.6"
9467+
resolved "https://registry.yarnpkg.com/react-custom-share/-/react-custom-share-0.4.6.tgz#13b17e9982bfd01dfe4c84d9bac1a8280ba1eea1"
94689468
dependencies:
94699469
intersection-observer "^0.5.0"
94709470
lodash.debounce "^4.0.8"
9471-
react-lorem-component "^0.13.0"
94729471

94739472
react-deep-force-update@^2.1.1:
94749473
version "2.1.1"

integrations/create-react-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dependencies": {
66
"emotion": "^9.2.4",
77
"react": "^16.4.1",
8-
"react-custom-share": "^0.3.0",
8+
"react-custom-share": "^0.4.6",
99
"react-dom": "^16.4.1",
1010
"react-icons": "^2.2.7",
1111
"react-scripts": "1.1.4",

integrations/create-react-app/yarn.lock

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,10 @@ interpret@^1.0.0:
34703470
version "1.1.0"
34713471
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"
34723472

3473+
intersection-observer@^0.5.0:
3474+
version "0.5.0"
3475+
resolved "https://registry.yarnpkg.com/intersection-observer/-/intersection-observer-0.5.0.tgz#9fe8bee3953c755b1485c38efd9633d535775ea6"
3476+
34733477
invariant@^2.2.2:
34743478
version "2.2.4"
34753479
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
@@ -5650,9 +5654,12 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.7:
56505654
minimist "^1.2.0"
56515655
strip-json-comments "~2.0.1"
56525656

5653-
react-custom-share@^0.3.0:
5654-
version "0.3.0"
5655-
resolved "https://registry.yarnpkg.com/react-custom-share/-/react-custom-share-0.3.0.tgz#57abc4bc3a83a49ce6e0b1e1688d8bec35353cb0"
5657+
react-custom-share@^0.4.6:
5658+
version "0.4.6"
5659+
resolved "https://registry.yarnpkg.com/react-custom-share/-/react-custom-share-0.4.6.tgz#13b17e9982bfd01dfe4c84d9bac1a8280ba1eea1"
5660+
dependencies:
5661+
intersection-observer "^0.5.0"
5662+
lodash.debounce "^4.0.8"
56565663

56575664
react-dev-utils@^5.0.1:
56585665
version "5.0.1"

integrations/gatsby/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"gatsby-transformer-remark": "^1.7.40",
2626
"gatsby-transformer-sharp": "^1.6.22",
2727
"lodash": "^4.17.5",
28-
"react-custom-share": "^0.3.0",
28+
"react-custom-share": "^0.4.6",
2929
"react-icons": "^2.2.7",
3030
"typeface-merriweather": "0.0.43",
3131
"typeface-montserrat": "0.0.43",

integrations/gatsby/yarn.lock

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5179,6 +5179,10 @@ interpret@^1.0.0:
51795179
version "1.1.0"
51805180
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"
51815181

5182+
intersection-observer@^0.5.0:
5183+
version "0.5.0"
5184+
resolved "https://registry.yarnpkg.com/intersection-observer/-/intersection-observer-0.5.0.tgz#9fe8bee3953c755b1485c38efd9633d535775ea6"
5185+
51825186
invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2, invariant@^2.2.4:
51835187
version "2.2.4"
51845188
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
@@ -6084,6 +6088,10 @@ lodash.clonedeep@^4.5.0:
60846088
version "4.5.0"
60856089
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
60866090

6091+
lodash.debounce@^4.0.8:
6092+
version "4.0.8"
6093+
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
6094+
60876095
lodash.defaults@^4.0.1, lodash.defaults@^4.2.0:
60886096
version "4.2.0"
60896097
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
@@ -8310,9 +8318,12 @@ rc@^1.0.1, rc@^1.1.2, rc@^1.1.6, rc@^1.2.7:
83108318
minimist "^1.2.0"
83118319
strip-json-comments "~2.0.1"
83128320

8313-
react-custom-share@^0.3.0:
8314-
version "0.3.0"
8315-
resolved "https://registry.yarnpkg.com/react-custom-share/-/react-custom-share-0.3.0.tgz#57abc4bc3a83a49ce6e0b1e1688d8bec35353cb0"
8321+
react-custom-share@^0.4.6:
8322+
version "0.4.6"
8323+
resolved "https://registry.yarnpkg.com/react-custom-share/-/react-custom-share-0.4.6.tgz#13b17e9982bfd01dfe4c84d9bac1a8280ba1eea1"
8324+
dependencies:
8325+
intersection-observer "^0.5.0"
8326+
lodash.debounce "^4.0.8"
83168327

83178328
react-deep-force-update@^2.1.1:
83188329
version "2.1.1"

src/styled/ShareBlockAside.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,32 +108,36 @@ class ShareBlockAside extends React.Component {
108108
};
109109

110110
setupObserver = () => {
111-
const options = { rootMargin: '0px', threshold: [0.5] };
112-
this.observer = new IntersectionObserver(this.handleIntersect, options);
111+
if (typeof window !== `undefined`) {
112+
const options = { rootMargin: '0px', threshold: [0.5] };
113+
this.observer = new IntersectionObserver(this.handleIntersect, options);
113114

114-
// add inline buttons to targets
115-
this.observerTargets.push(document.querySelector('.rcs-buttons--inline'));
115+
// add inline buttons to targets
116+
this.observerTargets.push(document.querySelector('.rcs-buttons--inline'));
116117

117-
// add page header to targets, if selector is provided
118-
const { pageHeaderSelector } = this.props;
119-
if (this.props.pageHeaderSelector) {
120-
this.observerTargets.push(document.querySelector(pageHeaderSelector));
121-
}
118+
// add page header to targets, if selector is provided
119+
const { pageHeaderSelector } = this.props;
120+
if (this.props.pageHeaderSelector) {
121+
this.observerTargets.push(document.querySelector(pageHeaderSelector));
122+
}
122123

123-
// observe the targets
124-
for (var value of this.observerTargets) {
125-
this.observer.observe(value);
124+
// observe the targets
125+
for (var value of this.observerTargets) {
126+
this.observer.observe(value);
127+
}
126128
}
127129
};
128130

129131
handleIntersect = (entries, observer) => {
130-
entries.forEach(entry => {
131-
if (this.state.fixedButtonsTranslation) {
132-
this.setState({
133-
fixedButtonsVisible: entry.intersectionRatio > 0.5 ? false : true,
134-
});
135-
}
136-
});
132+
if (typeof window !== `undefined`) {
133+
entries.forEach(entry => {
134+
if (this.state.fixedButtonsTranslation) {
135+
this.setState({
136+
fixedButtonsVisible: entry.intersectionRatio > 0.5 ? false : true,
137+
});
138+
}
139+
});
140+
}
137141
};
138142

139143
render() {

0 commit comments

Comments
 (0)