From 47d4afa3f6f043ba36221d1401b13d6dec223179 Mon Sep 17 00:00:00 2001
From: Ray Schamp <ray@scratch.mit.edu>
Date: Thu, 12 Apr 2018 17:03:04 -0400
Subject: [PATCH] Be more succinct with the open prop

---
 src/components/menu/menu.jsx | 38 ++++++++++++++----------------------
 src/containers/menu.jsx      |  6 +++---
 2 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/src/components/menu/menu.jsx b/src/components/menu/menu.jsx
index 543b998c8..ce443db55 100644
--- a/src/components/menu/menu.jsx
+++ b/src/components/menu/menu.jsx
@@ -8,35 +8,27 @@ const MenuComponent = ({
     className = '',
     children,
     componentRef,
-    open = false,
     place = 'right'
-}) => {
-    if (open) {
-        return (
-            <ul
-                className={classNames(
-                    styles.menu,
-                    className,
-                    {
-                        [styles.open]: open,
-                        [styles.left]: place === 'left',
-                        [styles.right]: place === 'right'
-                    }
-                )}
-                ref={componentRef}
-            >
-                {children}
-            </ul>
-        );
-    }
-    return null;
-};
+}) => (
+    <ul
+        className={classNames(
+            styles.menu,
+            className,
+            {
+                [styles.left]: place === 'left',
+                [styles.right]: place === 'right'
+            }
+        )}
+        ref={componentRef}
+    >
+        {children}
+    </ul>
+);
 
 MenuComponent.propTypes = {
     children: PropTypes.node,
     className: PropTypes.string,
     componentRef: PropTypes.func,
-    open: PropTypes.bool,
     place: PropTypes.oneOf(['left', 'right'])
 };
 
diff --git a/src/containers/menu.jsx b/src/containers/menu.jsx
index 9096e8617..865ad19d3 100644
--- a/src/containers/menu.jsx
+++ b/src/containers/menu.jsx
@@ -39,10 +39,10 @@ class Menu extends React.Component {
             children,
             ...props
         } = this.props;
+        if (!open) return null;
         return (
             <MenuComponent
                 componentRef={this.ref}
-                open={open}
                 {...props}
             >
                 {children}
@@ -53,8 +53,8 @@ class Menu extends React.Component {
 
 Menu.propTypes = {
     children: PropTypes.node,
-    onRequestClose: PropTypes.func,
-    open: PropTypes.bool
+    onRequestClose: PropTypes.func.isRequired,
+    open: PropTypes.bool.isRequired
 };
 
 export default Menu;
-- 
GitLab