refactor convos fetching to nav components, results in faster loading

This commit is contained in:
Danny Avila 2023-02-14 16:15:45 -05:00
parent e4d1ff2523
commit 742073fb89
8 changed files with 389 additions and 286 deletions

View file

@ -5,15 +5,11 @@ import TextChat from './components/main/TextChat';
import Nav from './components/Nav';
import MobileNav from './components/Nav/MobileNav';
import useDocumentTitle from '~/hooks/useDocumentTitle';
import { useDispatch, useSelector } from 'react-redux';
import { setConvos } from '~/store/convoSlice';
import { useSelector } from 'react-redux';
const App = () => {
const { messages } = useSelector((state) => state.messages);
const { title } = useSelector((state) => state.convo);
const dispatch = useDispatch();
const { data, error, isLoading, mutate } = swr('http://localhost:3050/convos', (res) => dispatch(setConvos(res)));
useDocumentTitle(title);
return (