Skip to content

Commit

Permalink
[fix] Unnecessary renders when modal is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Fuller authored and diasbruno committed Jun 20, 2017
1 parent 648cc2f commit 7da6ec8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ export default class Modal extends Component {
}

componentWillReceiveProps(newProps) {
if (newProps.isOpen) refCount.add(this);
if (!newProps.isOpen) refCount.remove(this);
const { isOpen } = newProps;
// Stop unnecessary renders if modal is remaining closed
if (!this.props.isOpen && !isOpen) return;

if (isOpen) refCount.add(this);
if (!isOpen) refCount.remove(this);
const currentParent = getParentElement(this.props.parentSelector);
const newParent = getParentElement(newProps.parentSelector);

Expand Down

0 comments on commit 7da6ec8

Please sign in to comment.