Skip to content

Commit

Permalink
dispatch getRandomPhotos on page load on if postsCount is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
rishavbharti committed Jun 23, 2022
1 parent 068a989 commit 53718f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pages/Feed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const Feed = () => {
const postsCount = useSelector(getTotalPosts);

useEffect(() => {
dispatch(getRandomPhotos({ initialLoad: postsCount === 0, count: 10 }));
if (!postsCount && !loading) {
dispatch(getRandomPhotos({ initialLoad: true, count: 10 }));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [dispatch]);

Expand Down

1 comment on commit 53718f3

@vercel
Copy link

@vercel vercel bot commented on 53718f3 Jun 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

growwgram – ./

growwgram-rishavbharti.vercel.app
growwgram-git-main-rishavbharti.vercel.app

Please sign in to comment.