Skip to content

Commit

Permalink
Move useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
DustyReagan committed Nov 13, 2024
1 parent a97c24b commit b8e8858
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions client/reader/recent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ const Recent = () => {
}
}, [ isWide, data?.items, selectedItem ] );

// When the selected feed changes, clear the selected item and reset the page to 1.
useEffect( () => {
setSelectedItem( null );
setView( ( prevView ) => ( {
...prevView,
page: 1,
} ) );
}, [ selectedRecentSidebarFeedId ] );

const [ hasLoadedItems, setHasLoadedItems ] = useState( false );
const isEmpty = ! data?.items || data.items.length === 0;

Expand All @@ -170,15 +179,6 @@ const Recent = () => {
return null;
}

// When the selected feed changes, clear the selected item and reset the page to 1.
useEffect( () => {
setSelectedItem( null );
setView( ( prevView ) => ( {
...prevView,
page: 1,
} ) );
}, [ selectedRecentSidebarFeedId ] );

return (
<div className="recent-feed">
<div
Expand Down

0 comments on commit b8e8858

Please sign in to comment.