使用链接而不是<a href="">

时间:2019-05-27 08:44:41

标签: javascript html reactjs

I have some issues in my ReactJS project. I was using a hamburger menu in my site's corner and I was using to point to the other pages. The issue is that I had to change from <li><a href="/LoginPage">Login Page</a></li> to <li><Link to="/LoginPage">Login Page</Link></li> and then my Hamburger tab does not close itself after I press on some certain page. I was using state and some javascript code for it. Now since it didn't work I tried some changes in my JSX file: <Link to={{pathname: "/LoginPage", state: closeSideDrawer}}>Login Page</Link> and I had this code as well

render() {
        this.state = {
            user: null,
            sideDrawerOpen: false
        };
        let closeSideDrawer = () => {
            this.setState((prevState) => {
                return {sideDrawerOpen: prevState.sideDrawerOpen};
            });
        }
}

0 个答案:

没有答案