import React from 'react'; import { Route, Switch } from 'react-router-dom'; import Swipeable from 'react-swipeable'; import burgerIcon from '@fortawesome/fontawesome-free-solid/faBars'; import FontAwesomeIcon from '@fortawesome/react-fontawesome'; import classnames from 'classnames'; import * as PropTypes from 'prop-types'; import ShortUrlsVisits from '../visits/ShortUrlVisits'; import './MenuLayout.scss'; import { serverType } from '../servers/prop-types'; const MenuLayout = (TagsList, ShortUrls, AsideMenu, CreateShortUrl) => class MenuLayout extends React.Component { static propTypes = { match: PropTypes.object, selectServer: PropTypes.func, location: PropTypes.object, selectedServer: serverType, }; state = { showSideBar: false }; // FIXME Shouldn't use componentWillMount, but this code has to be run before children components are rendered /* eslint react/no-deprecated: "off" */ componentWillMount() { const { match, selectServer } = this.props; const { params: { serverId } } = match; selectServer(serverId); } componentDidUpdate(prevProps) { const { location } = this.props; // Hide sidebar when location changes if (location !== prevProps.location) { this.setState({ showSideBar: false }); } } render() { const { selectedServer } = this.props; const burgerClasses = classnames('menu-layout__burger-icon', { 'menu-layout__burger-icon--active': this.state.showSideBar, }); return ( this.setState(({ showSideBar }) => ({ showSideBar: !showSideBar }))} /> this.setState({ showSideBar: false })} onSwipedRight={() => this.setState({ showSideBar: true })} >
this.setState({ showSideBar: false })} >
); } }; export default MenuLayout;