// @flow import React from "react" import { NavLink } from "react-router-dom" import FontAwesomeIcon from "@fortawesome/react-fontawesome" import faBars from "@fortawesome/fontawesome-free-solid/faBars" import "./index.css" type Props = {} type State = { showMenu: boolean } class Navbar extends React.Component { static defaultProps: Props changeMenu: number constructor(props: Props) { super(props) this.changeMenu = 800 if (window.innerWidth <= this.changeMenu) { this.state = { showMenu: false } } else { this.state = { showMenu: true } } } toggleMenu = () => { if (window.innerWidth <= this.changeMenu || !this.state.showMenu) { this.setState(prev => ({ showMenu: !prev.showMenu })) } } render() { let menuButton = null if (window.innerWidth <= this.changeMenu) { menuButton = (
) } return (
{menuButton} {this.state.showMenu ? (
Home Projects Experience Contact
) : null}
) } } export default Navbar