fix: fouc
This commit is contained in:
parent
7848215ac6
commit
b2c6b09f06
|
@ -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">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user