Skip to content

Commit

Permalink
Try to fix infinite re-rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
gabro committed May 4, 2023
1 parent e9dd4d6 commit 76926d4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as ReactDOM from 'react-dom';
import cx from 'classnames';
import debounce = require('lodash/debounce');
import uniq = require('lodash/uniq');
import isEqual = require('lodash/isEqual');
import { getContextWrapper, Children } from '../utils';

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

this.setState({
const newState = {
child: {
width: childWidth,
height: childHeight,
Expand All @@ -272,7 +273,14 @@ export class Popover extends React.Component<Popover.Props, State> {
x: popoverX,
y: popoverY
}
});
};

if (
!isEqual(this.state.child, newState.child) ||
!isEqual(this.state.popover, newState.popover)
) {
this.setState(newState);
}
}
};

Expand Down

0 comments on commit 76926d4

Please sign in to comment.