class homeNotLoggedIn extends React.Component {
componentDidMount() {
function logout(){
localStorage.clear()
location.reload()
}
}
render() {
return (
<div>
<div className="nav_bar">
<button id='logout' onClick={ logout() }>
I'm currently facing a challenge as I cannot relocate the 'logout()' function outside of 'componentDidMount'. This is because I require access to both localStorage and the client's location property. While I understand that it will result in an error saying "logout is not defined", I am unsure how to properly define it in this scenario.