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

Commit 47677e9

Browse files
mfedderlyFezVrasta
authored andcommitted
Fix infinite loop (#320)
Popper.js' componentDidUpdate fails the props change test, which calls updatePopperInstance, which eventually causes componentDidUpdate to get called again. By using a deepEquals comparison on modifiers we correctly determine that the props did not update, and break the loop.
1 parent b451e96 commit 47677e9

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

.size-snapshot.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"dist/index.umd.js": {
3-
"bundled": 67296,
4-
"minified": 23836,
5-
"gzipped": 7176
3+
"bundled": 88323,
4+
"minified": 32847,
5+
"gzipped": 9575
66
},
77
"dist/index.umd.min.js": {
8-
"bundled": 31932,
9-
"minified": 12958,
10-
"gzipped": 4186
8+
"bundled": 52955,
9+
"minified": 21926,
10+
"gzipped": 6619
1111
},
1212
"dist/index.esm.js": {
13-
"bundled": 12751,
14-
"minified": 7575,
15-
"gzipped": 2077,
13+
"bundled": 12824,
14+
"minified": 7630,
15+
"gzipped": 2103,
1616
"treeshaked": {
1717
"rollup": {
18-
"code": 3790,
19-
"import_statements": 137
18+
"code": 3829,
19+
"import_statements": 163
2020
},
2121
"webpack": {
22-
"code": 4900
22+
"code": 4978
2323
}
2424
}
2525
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"dependencies": {
6464
"@babel/runtime": "^7.1.2",
6565
"create-react-context": "^0.3.0",
66+
"deep-equal": "^1.1.1",
6667
"popper.js": "^1.14.4",
6768
"prop-types": "^15.6.1",
6869
"typed-styles": "^0.0.7",

src/Popper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @flow
2+
import deepEqual from "deep-equal";
23
import * as React from 'react';
34
import PopperJS, {
45
type Placement,
@@ -165,7 +166,7 @@ export class InnerPopper extends React.Component<PopperProps, PopperState> {
165166
this.props.placement !== prevProps.placement ||
166167
this.props.referenceElement !== prevProps.referenceElement ||
167168
this.props.positionFixed !== prevProps.positionFixed ||
168-
this.props.modifiers !== prevProps.modifiers
169+
!deepEqual(this.props.modifiers, prevProps.modifiers, {strict: true})
169170
) {
170171

171172
// develop only check that modifiers isn't being updated needlessly

yarn.lock

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,6 +2661,18 @@ decode-uri-component@^0.2.0:
26612661
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
26622662
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
26632663

2664+
deep-equal@^1.1.1:
2665+
version "1.1.1"
2666+
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a"
2667+
integrity sha1-tcmMlCzv+vfLBR4k4UNKJaLmB2o=
2668+
dependencies:
2669+
is-arguments "^1.0.4"
2670+
is-date-object "^1.0.1"
2671+
is-regex "^1.0.4"
2672+
object-is "^1.0.1"
2673+
object-keys "^1.1.1"
2674+
regexp.prototype.flags "^1.2.0"
2675+
26642676
deep-extend@^0.6.0:
26652677
version "0.6.0"
26662678
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac"
@@ -4314,6 +4326,11 @@ is-accessor-descriptor@^1.0.0:
43144326
dependencies:
43154327
kind-of "^6.0.0"
43164328

4329+
is-arguments@^1.0.4:
4330+
version "1.0.4"
4331+
resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.0.4.tgz#3faf966c7cba0ff437fb31f6250082fcf0448cf3"
4332+
integrity sha1-P6+WbHy6D/Q3+zH2JQCC/PBEjPM=
4333+
43174334
is-arrayish@^0.2.1:
43184335
version "0.2.1"
43194336
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
@@ -7545,6 +7562,13 @@ regexp-tree@^0.1.0:
75457562
colors "^1.1.2"
75467563
yargs "^10.0.3"
75477564

7565+
regexp.prototype.flags@^1.2.0:
7566+
version "1.2.0"
7567+
resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.2.0.tgz#6b30724e306a27833eeb171b66ac8890ba37e41c"
7568+
integrity sha1-azByTjBqJ4M+6xcbZqyIkLo35Bw=
7569+
dependencies:
7570+
define-properties "^1.1.2"
7571+
75487572
regexpp@^1.0.1:
75497573
version "1.1.0"
75507574
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab"

0 commit comments

Comments
 (0)