@@ -188,8 +188,13 @@ return /******/ (function(modules) { // webpackBootstrap
188188 } , {
189189 key : 'componentWillReceiveProps' ,
190190 value : function componentWillReceiveProps ( newProps ) {
191- if ( newProps . isOpen ) refCount . add ( this ) ;
192- if ( ! newProps . isOpen ) refCount . remove ( this ) ;
191+ var isOpen = newProps . isOpen ;
192+ // Stop unnecessary renders if modal is remaining closed
193+
194+ if ( ! this . props . isOpen && ! isOpen ) return ;
195+
196+ if ( isOpen ) refCount . add ( this ) ;
197+ if ( ! isOpen ) refCount . remove ( this ) ;
193198 var currentParent = getParentElement ( this . props . parentSelector ) ;
194199 var newParent = getParentElement ( newProps . parentSelector ) ;
195200
@@ -1385,6 +1390,14 @@ return /******/ (function(modules) { // webpackBootstrap
13851390 _this . focusAfterRender = focus ;
13861391 } ;
13871392
1393+ _this . setOverlayRef = function ( overlay ) {
1394+ _this . overlay = overlay ;
1395+ } ;
1396+
1397+ _this . setContentRef = function ( content ) {
1398+ _this . content = content ;
1399+ } ;
1400+
13881401 _this . afterClose = function ( ) {
13891402 focusManager . returnFocus ( ) ;
13901403 focusManager . teardownScopedFocus ( ) ;
@@ -1416,7 +1429,7 @@ return /******/ (function(modules) { // webpackBootstrap
14161429 } ;
14171430
14181431 _this . focusContent = function ( ) {
1419- return ! _this . contentHasFocus ( ) && _this . content . focus ( ) ;
1432+ return _this . content && ! _this . contentHasFocus ( ) && _this . content . focus ( ) ;
14201433 } ;
14211434
14221435 _this . closeWithTimeout = function ( ) {
@@ -1544,8 +1557,6 @@ return /******/ (function(modules) { // webpackBootstrap
15441557 } , {
15451558 key : 'render' ,
15461559 value : function render ( ) {
1547- var _this2 = this ;
1548-
15491560 var _props = this . props ,
15501561 className = _props . className ,
15511562 overlayClassName = _props . overlayClassName ,
@@ -1557,18 +1568,14 @@ return /******/ (function(modules) { // webpackBootstrap
15571568 return this . shouldBeClosed ( ) ? _react2 . default . createElement ( 'div' , null ) : _react2 . default . createElement (
15581569 'div' ,
15591570 {
1560- ref : function ref ( overlay ) {
1561- _this2 . overlay = overlay ;
1562- } ,
1571+ ref : this . setOverlayRef ,
15631572 className : this . buildClassName ( 'overlay' , overlayClassName ) ,
15641573 style : _extends ( { } , overlayStyles , this . props . style . overlay ) ,
15651574 onClick : this . handleOverlayOnClick } ,
15661575 _react2 . default . createElement (
15671576 'div' ,
15681577 {
1569- ref : function ref ( content ) {
1570- _this2 . content = content ;
1571- } ,
1578+ ref : this . setContentRef ,
15721579 style : _extends ( { } , contentStyles , this . props . style . content ) ,
15731580 className : this . buildClassName ( 'content' , className ) ,
15741581 tabIndex : '-1' ,
0 commit comments