I have a react component and I've added 2 links.
One link will show the login link and the other with show the logout.
I just don't want both to show so on componentDidMount I've added a condition which will hide either one or the other.
Here is the code:
class Navigation extends Component {
componentDidMount() {
let logged = true;
if (logged) {
document.getElementById('login').style.display = 'none';
} else {
document.getElementById('logout').style.display = 'none';
}
}
}
render() {
return (
<div>
<ul>
<li id="login"><a href="#login">Login</a></li>
<li id="logout"><a href="#logout">Logout</a></li>
</ul>
</div>
);
}
}
export default Navigation;
The issue is not nothing is being hidden either way so it's not working.
How can I fix this so I can get the condition to hide either one or the other?