diff --git a/src/components/pages/feed.js b/src/components/pages/feed.js index 23b3688..830e2f6 100644 --- a/src/components/pages/feed.js +++ b/src/components/pages/feed.js @@ -64,9 +64,11 @@ const Feed = (props) => { ); }, []); - const _handleTimelineLoaded = () => setState({...state, - postsRendered: true, - }); + const _handleTimelineLoaded = () => { + setState({...state, + postsRendered: true, + }); + }; let endOfTimelineMessage = <>; if (state.postsRendered) { diff --git a/src/components/posts/post.js b/src/components/posts/post.js index 6b89acd..e4f10c8 100644 --- a/src/components/posts/post.js +++ b/src/components/posts/post.js @@ -220,13 +220,14 @@ export const PostByData = (props) => { own, loaded: true }); - - if (props.onPostLoaded != null) { - props.onPostLoaded(); - } }); }, []); + useEffect(() => { + // This is run after the state has been updated + props.onPostLoaded(); + }, [state]) + const _handleFavourite = async () => { let newStatus; diff --git a/src/components/posts/timeline-view.js b/src/components/posts/timeline-view.js index 208603f..8dbc6e4 100644 --- a/src/components/posts/timeline-view.js +++ b/src/components/posts/timeline-view.js @@ -23,7 +23,9 @@ const TimelineView = (props) => { } }, [postsLoaded]); - _handlePostLoaded = () => setPostsLoaded(postsLoaded + 1); + const _handlePostLoaded = () => { + setPostsLoaded(postsLoaded + 1); + } return (