import React from 'react' import { Menu } from 'react-feather' import Link from 'next/link' import config from '../config' interface Props { height?: number } interface States { scrolled: boolean } export default class Navbar extends React.Component { private height = 80 private menuRef = undefined constructor(props: Props) { super(props) if (this.props.height) { this.height = this.props.height } } setRef = element => { this.menuRef = element } onScroll = () => { this.setState({ scrolled: window.pageYOffset > 207 }) } componentDidMount() { if (window.location.origin !== config.domain) { window.location.replace(`${config.domain}${window.location.pathname}`) } window.addEventListener('scroll', this.onScroll) } componentWillUnmount() { window.removeEventListener('scroll', this.onScroll) } onClick = () => { this.menuRef.classList.toggle("shown") } render() { const height = this.props.height || 80 // if (!this.state.scrolled) // console.log(this.state.scrolled) return ( ) } }