From a28a8916d9a4ead9750771a4cf02208ec33b366c Mon Sep 17 00:00:00 2001 From: Mitchell Simon Date: Tue, 3 Sep 2019 00:34:08 -0400 Subject: [PATCH] Refactor navbar menu button rendering --- src/components/Navbar/index.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index c102710..0c8cd97 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -18,13 +18,23 @@ class Navbar extends React.Component<{}, State> { this.toggleMenu = this.toggleMenu.bind(this) this.renderButtons = this.renderButtons.bind(this) this.closeMenu = this.closeMenu.bind(this) + this.menuButton = this.menuButton.bind(this) } public render() { - let menuButton: JSX.Element | null = null + return ( +
+ {this.menuButton()} + {this.state.showMenu && ( +
{this.renderButtons()}
+ )} +
+ ) + } + private menuButton() { if (this.isMobile()) { - menuButton = ( + return (
{ ) } - return ( -
- {menuButton} - {this.state.showMenu ? ( -
{this.renderButtons()}
- ) : null} -
- ) + return null } private isMobile() {