From c91704560c7a09e23d621cee0ba7f86574690706 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 25 Feb 2019 00:59:20 +0300 Subject: Modal is memo --- vnext/src/components/Modal.js | 50 +++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/vnext/src/components/Modal.js b/vnext/src/components/Modal.js index 971efe91..5ee8c3ec 100644 --- a/vnext/src/components/Modal.js +++ b/vnext/src/components/Modal.js @@ -3,39 +3,33 @@ import PropTypes from 'prop-types'; import Icon from './Icon'; -export default class Modal extends React.Component { - render() { - // Render nothing if the "show" prop is false - if (!this.props.show) { - return null; - } - - // The gray background - const backdropStyle = { - position: 'fixed', - top: 0, - bottom: 0, - left: 0, - right: 0, - backgroundColor: 'rgba(0, 0, 0, 0.3)', - padding: 50 - }; - - return ( -
-
-
-
- -
+function Modal(props) { + // The gray background + const backdropStyle = { + position: 'fixed', + top: 0, + bottom: 0, + left: 0, + right: 0, + backgroundColor: 'rgba(0, 0, 0, 0.3)', + padding: 50 + }; + return props.show ? ( +
+
+
+
+
- {this.props.children}
+ {this.props.children}
- ); - } +
+ ) : (null); } +export default React.memo(Modal); + Modal.propTypes = { onClose: PropTypes.func.isRequired, show: PropTypes.bool, -- cgit v1.2.3