fix: fouc

This commit is contained in:
cha0s 2020-07-27 22:19:41 -05:00
parent 7848215ac6
commit b2c6b09f06

View File

@ -11,19 +11,22 @@ export default function Home() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const favorites = useSelector(favoriteChannelsSelector); const favorites = useSelector(favoriteChannelsSelector);
const user = useSelector(userSelector); const user = useSelector(userSelector);
let path;
if (favorites.length > 0) {
path = `/chat/r/${favorites[0]}`;
}
else if (user.id) {
path = '/chat';
}
useEffect(() => { useEffect(() => {
let path;
if (favorites.length > 0) {
path = `/chat/r/${favorites[0]}`;
}
else if (user.id) {
path = '/chat';
}
if (path) { if (path) {
dispatch(replace(path)); dispatch(replace(path));
} }
window.document.title = 'reddichat'; window.document.title = 'reddichat';
}); });
if (path) {
return null;
}
return ( return (
<div className="home"> <div className="home">
<div className="home__inner"> <div className="home__inner">