Skip to content

Commit

Permalink
Fix major bug of switching communities
Browse files Browse the repository at this point in the history
  • Loading branch information
tanish35 committed Oct 16, 2024
1 parent c6a742f commit b1f910c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontend/src/components/Posts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const Posts = () => {
const { userDetails, loadingUser } = useUser();
const navigate = useNavigate();
const toast = useToast();
const fetchInitialized = useRef(false);

const fetchPosts = async () => {
try {
Expand Down Expand Up @@ -70,12 +71,23 @@ const Posts = () => {
};

useEffect(() => {
if (!fetchInitialized.current) {
fetchInitialized.current = true;
return;
}
setPosts([]);
setPage(1);
setHasMore(true);
fetchPosts();
}, [selectedCommunity]);

// useEffect(() => {
// setPosts([]);
// setPage(1);
// setHasMore(true);
// fetchPosts();
// }, [selectedCommunity]);

useEffect(() => {
const fetchCommunities = async () => {
setLoading(true);
Expand Down

0 comments on commit b1f910c

Please sign in to comment.