Skip to content

Commit 76926d4

Browse files
committed
Try to fix infinite re-rendering
1 parent e9dd4d6 commit 76926d4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Popover/Popover.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as ReactDOM from 'react-dom';
33
import cx from 'classnames';
44
import debounce = require('lodash/debounce');
55
import uniq = require('lodash/uniq');
6+
import isEqual = require('lodash/isEqual');
67
import { getContextWrapper, Children } from '../utils';
78

89
const NO_SIZE_WRAPPER = 'no-size-wrapper';
@@ -259,7 +260,7 @@ export class Popover extends React.Component<Popover.Props, State> {
259260
const { top: childY, left: childX } = this.getOffsetRect(this.children);
260261
const { top: popoverY, left: popoverX } = this.getOffsetRect(popoverNode);
261262

262-
this.setState({
263+
const newState = {
263264
child: {
264265
width: childWidth,
265266
height: childHeight,
@@ -272,7 +273,14 @@ export class Popover extends React.Component<Popover.Props, State> {
272273
x: popoverX,
273274
y: popoverY
274275
}
275-
});
276+
};
277+
278+
if (
279+
!isEqual(this.state.child, newState.child) ||
280+
!isEqual(this.state.popover, newState.popover)
281+
) {
282+
this.setState(newState);
283+
}
276284
}
277285
};
278286

0 commit comments

Comments
 (0)