return (
<div>
{ loggedIn !== null &&
<Router>
...
</Router>
}
</div>
);
const [loggedIn, setLoggedIn] = useState(null);
useEffect(() => {
const loggedUser = localStorage.getItem('user');
setLoggedIn(Boolean(loggedUser));
}, []);